Posts

PHP - Displaying MySQL Column Names and Values via PHP

$result = mysql_query($sql); if ($result) {         $total_row = mysql_num_rows($result); } if ($total_row > 0) {         while ($tableRow = mysql_fetch_assoc($result)) {                $result_body.= "<item>";                foreach ($tableRow as $column => $value) {                     $result_body.= "<{$column}><![CDATA[{$value}]]></{$column}>";                }                $result_body.= "</item>";         } }

PHP - CheckBoxList

# Form Input: < form id =" myForm " method =" post "> < input id =" CheckBoxList[] " type =" checkbox " name =" CheckBoxList[] " value =" 1 " / > < input id =" CheckBoxList[] " type =" checkbox " name =" CheckBoxList[] " value =" 4 " checked =" checked " / > < input id =" CheckBoxList[] " type =" checkbox " name =" CheckBoxList[] " value =" 3 " checked =" checked " / > < input type =" submit " name =" ButtonOK " value =" Save " / > < /form>   # PHP Action: $access_menu_id_array = $_POST["CheckBoxList"]; for($i=0; $i<sizeof($access_menu_id_array); $i++) { $access_menu_id .= $access_menu_id_array[$i]; if ((i+1) < sizeof($access_menu_id_array)) $access_menu_id .= ","; }

PHP - Array 2 Dimension

<?php      $car1[0][1]="Jeep Grand Cherokee";      $car1[0][2]=2002;      $car1[1][1]="Jeep Wrangler";      $car1[1][2]=2002;      $car1[2][1]="Jeep Liberty";      $car1[2][2]=2003;      $car1[3][1]="Jeep Cherokee Briarwood";      $car1[3][2]=2003;      for($x=0; $x<4;$x++)      {           for($i=1; $i<3;$i++)           {                echo $car1[$x][$i]."<br>";           }      } ?> Reference : http://www.pctalknet.com/php/variables.php

C# - Get Path from file path

String _file = "c:\monthly_report\2012\07_JUL\2012_07.xls"; String _path = System.IO.Path.GetDirectoryName(_file); >> Result _path = c:\monthly_report\2012\07_JUL

C# - if statement (shorthand)

In normal statement, we use if statement : Boolean _valid = false; if (_command.ToLower() == "get_data")      _valid = true; else      _valid = false; We can use the shorthand statement:      _valid = _command.ToLower() == "get_data"? true : false;

MSSQL - Date Format

Web Reference : www.sql-server-helper.com Standard Date Formats Date Format SQL Statement Sample Output Mon DD YYYY 1 HH:MIAM (or PM) SELECT CONVERT(VARCHAR(20), GETDATE(), 100) Jan 1 2005 1:29PM 1 MM/DD/YY SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] 11/23/98 MM/DD/YYYY SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] 11/23/1998 YY.MM.DD SELECT CONVERT(VARCHAR(8), GETDATE(), 2) AS [YY.MM.DD] 72.01.01 YYYY.MM.DD SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD] 1972.01.01 ...

MSSQL - DATEADD Function

Syntax: DATEADD (datepart , number , date ) Datepart Abbreviations year yy, yyyy quarter qq, q month mm, m dayofyear dy, y day dd, d week wk, ww weekday dw, w hour hh mi...