in_array with multible select "PHP"
<?php
$i=0;
while ($i < $num) {
$actaddname = mysql_result($query, $i, \"actadd_name\");
$i++;
}
while ($row_add = mysql_fetch_array($add_tool)) {
$addtool = $row_add['addtool_name'];
if (FALSE != 0 && in_array($addtool, $actaddname)) {
$selected = \" selected\";
} else {
$selected = \"\";
}
print \"$selected ----- $addtool <br />\";
}
?>
I'm sure there is something I didn't do here.
GDVS posted this at 10:09 — 1st April 2006.
They have: 36 posts
Joined: Mar 2006
One thing the leaps out at me is FALSE != 0, FALSE always equals 0 so it's never going to match anything.
AYYASH posted this at 05:32 — 2nd April 2006.
He has: 10 posts
Joined: Jan 2004
I've figuered out the problem and solve it. The way I did it before is going to take only the last result of the loop. I should take the result of the while loop and put into array.
so itshould be something like this:
<?php
$i=0;
$actaddname = array();
while ($i < $num) {
$actaddname[] = mysql_result($query, $i, \"actadd_name\");
$i++;
}
?>
Thanks for your reply.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.