foreach
Posted: Thu Sep 23, 2010 4:35 am
Hi,
It's very simple question but am not getting the right syntax -
Basically - i have a table with the column for ids.
Now when user enters that id in the form - i want that entered id to be matched against all the ids available in that table in database -
But i can not iterate through the foreach loop - it just match it with the first value and display "not found"...
I know it's something simple am missing - can anyone please shed some light on it.
Thanks
It's very simple question but am not getting the right syntax -
Basically - i have a table with the column for ids.
Now when user enters that id in the form - i want that entered id to be matched against all the ids available in that table in database -
Code: Select all
mysql_select_db($db,$link);
$query = "select xid from test";
$result = mysql_query($query, $link) or die(mysql_error());
$row = mysql_fetch_array($result);
foreach ($row as $val)
{
if($val == $CustomerEnteredID)
{
// DO THIS
}
else
{
echo "not found";
}
}
I know it's something simple am missing - can anyone please shed some light on it.
Thanks