Wednesday, December 22, 2004

:: Compare Date :- BezakaN Masa ::

Anyway, in PHP, the following code sample should help


$dateDiff = mktime(12,0,0,04,20,2003) - mktime(11,0,0,04,20,2003);
echo 'Difference in seconds: ' . $dateDiff . '
';

echo 'Years Difference = '. floor($dateDiff/365/60/60/24);
echo 'Months Difference = '. floor($dateDiff/60/60/24/7/4);
echo 'Weeks Difference = '. floor($dateDiff/60/60/24/7);
echo 'Days Difference = '. floor($dateDiff/60/60/24);
echo 'Hours Difference = '. floor($dateDiff/60/60);
echo 'Minutes Difference = '. floor($dateDiff/60);

evertyhing self explainatory hehe
klu nak compare time better used mktime so u calculation will be correct
.. take from the NET..

Saturday, December 11, 2004

:: Mysql (mysql_fetch_object) ::


mysql_fetch_object

1) akan amik dr database field name... klu mysql_fetch_array kiter akan quote kan
dier nyer row number sbg output..

2) tp mysql_fetch_object klu kiter nk quote kan output dier.. kener guner kan
nama field exactly..


speed wise.. samer jer..
e:g
$row = mysql_fetch_object($result);

/* this is valid */
echo $row->field;
/* this is invalid */
// echo $row->0;


selepas ku membaca manual.. nk buat drop down..

Thursday, December 09, 2004

:: Alternate Color::

$query="SELECT * FROM ".$tablename." WHERE cst_country LIKE '%$s_country%'";
$res=$dbHandle[$DBIndex]->RunQuery($query);
$color1 = "#F7EBDE";
$color2 = "#F7DFCE";

$row_count = 0;
echo"<--table cellspacing=0 cellpadding=0 border=1 valign=top-->";
while ($row = $res->fetchRow()) {
$row_color = ($row_count % 2) ? $color1 : $color2;

$i_value=number_format($row['cst_value'], 3, '.', '');
echo "<--tr bgcolor=\"$row_color\"-->";

echo "<--/tr-->";

$row_count++;
}
echo"<--/table>

1) Declare the desired color $color1 and $color2 and $row_count=0
2) Pastuh letak kan kira2 dier ( $row_color = ($row_count % 2) ? $color1 : $color2; ) dalam looop
3) then letakkan bgcolor=$row_color dlm row kiter
4) buat increment utk row color $row_count++

Tuesday, December 07, 2004

:: Friend code try to translate ::

$_SERVER['HTTP_HOST'] == kuar kan server nyer hostname sesuai msaer nk link kan image so the file is transferable