Hello guys
I'm trying to find a value which is into an array inside another array (hope it makes
sense). The code:
$query = "select cat_code from authorxcat where author_code=$mod_author";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$query_aux = "select * from categories order by cat_name";
$result_aux = mysql_query($query_aux) or die(mysql_error());
while ($row_aux = mysql_fetch_array($result_aux))
{
if (in_array($row_aux["cat_code"],$row))
{
echo "<tr><td class=\"nolink\">".$row_aux["cat_name"]."</td>
<td><input type=\"checkbox\" name=\"".$row_aux["cat_name"]."\"
value=\""
.$row_aux["cat_code"]."\" checked></td></tr>";
}
else
{
echo "<tr><td class=\"nolink\">".$row_aux["cat_name"]."</td>
<td><input type=\"checkbox\" name=\"".$row_aux["cat_name"]."\" value=\""
.$row_aux["cat_code"]."\"></td></tr>";
}
}
Well, I'll try to explain it:
The first query ($query) is supposed to find some "categories" codes and
store them into the $row array.
Then I just store all the categories codes into another array called $row_aux.
Then I walk through the $row_aux array and check, in every step, if the current code
is also into the $row array and according to that the output should be different.
The problem is that no matter how many items there are in the $row array, the
condition
inside the While becomes true just once and not the number of times it should.
Hope it is clear enough.
Thanks in advanced for your help.
*******************************************************
Wilmar P�rez
Network Administrator
Library System
Tel: ++57(4)2105962
University of Antioquia
Medell�n - Colombia
2002
*******************************************************
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php