VALID or NOT??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

VALID or NOT??

Post 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???
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you echoed all the relevant variables to check their values?

Mac
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

Post 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???
Post Reply