saronoff,
Thanks for the help but I am not getting all of it. I think I need to explain a bit more.
I have 2 queries pulling back info from 2 different tables.
1. is the list of all categories and
$category = mysql_query("select id, name, active from category");
- is a list of the categories that are selected from that list.
$selCat = mysql_query("select category from selCategory where id= $id");
so with the first query I use a while loop to populate the select list. no problem.
<SELECT NAME="lstCategory" SIZE="5" MULTIPLE>
while($row = mysql_fetch_array($category)){
echo "<option value=";
echo $row["id"];
echo ">";
echo $row["catName"];
}
</SELECT>
I see what you are getting at with the foreach loop but I cannot get it to work. I have also tried a while loop to no avail.
<SELECT NAME="lstCategory" SIZE="5" MULTIPLE>
while($row = mysql_fetch_array($category)){
echo "<option value=";
echo $row["id"];
while($rows = mysql_fetch_array($selCat)){
if($row["id"] == $rows["category"]){
echo " SELECTED";
}
}
echo ">";
echo $row["catName"];
}
</SELECT>
This does not work and I do not know why. From what I can tell the inner while loop only runs the first time through the outer loop.
I am losing my mind over this, I know it cannot be this hard. I am new to PHP but I have done this logic in other languages and made it work.
On another note, I had asked the question before to this forum about echo and print and the answer I got was that echo was faster, that is why I use it. What do you mean echo is lower level?
Thanks..