Page 1 of 1

VALID or NOT??

Posted: Tue Feb 03, 2004 7:41 am
by apek
i just curious about this code below...
it just a snippet of code..

Code: Select all

$viewCheck=query("SELECT id FROM tempfailure WHERE id = MONTH('{$senarai["waktuTamat"]}') ORDER BY id", $link, __LINE__, __FILE__);
$periksa=mysql_fetch_array($viewCheck, MYSQL_ASSOC);
    
	if (date("n",$senarai["waktuTamat"])==$periksa["id"])
    {
$nilai=$periksa["jumlah"]+1;
$SQLupd=query("UPDATE tempfailure SET jumlah = '$nilai'  WHERE id =MONTH('{$senarai["waktuTamat"]}')", $link, __LINE__, __FILE__);
    }
first i really curious about the MONTH function...is it valid??
the MONTH('{$senarai["waktuTamat"]}') means i want to fetch only month from the previous query...

and the

Code: Select all

if (date("n",$senarai["waktuTamat"])==$periksa["id"])

means i want to do IF to the id (month without leading zero) and the previous query...

why i curious is i can't get the output i want from this code...
anybody can help???

Posted: Tue Feb 03, 2004 9:10 am
by twigletmac
Have you echoed all the relevant variables to check their values?

Mac

Posted: Tue Feb 03, 2004 10:47 am
by apek
yup...
but i dont know why the output is not like i want...

Code: Select all

$viewCheck=query("SELECT * FROM tempfailure WHERE id = DATE_FORMAT('{$senarai["waktuTamat"]}','%m') ORDER BY id", $link, __LINE__, __FILE__);
$periksa=mysql_fetch_array($viewCheck);
above is just a snippet of my code...
i changed it a bit from the last time i posted here...
what i want is...
id is an id represents 01,02,03....12(months)...
$senarai["waktuTamat"] is date in timestamp format....i query it earlier..
and i want to select all id(or months) that same to the months in $senarai["waktuTamat"] ..which i queried earlier...
anybody can help me???