Forum Moderators: coopster
This is my code:
<select name="select" size="10" multiple>
<?php
echo $cat_row['cat_id'];
//$category is everything from my category table whitch contains all the categories
while ($category_row = mysql_fetch_array($category)) {
// $cat is everything from table user_category
while ($cat_row = mysql_fetch_array($cat)) {
if ($category_row['cat_id'] == $cat_row['cat_id']) {
echo "<option selected value=".$category_row['cat_id'].">".$category_row['cat_name']."</option>";
} else {
echo "<option value=".$category_row['cat_id'].">".$category_row['cat_name']."</option>";
}
}
}
?>
</select>
Hope you understand this code...its a bit messy.... :)
My category table has 10 records.
My user_cat table has 2 records on the current user.
When the current user load the page, the listbox should display all the 10 records from the category table, but highlight those that he has selected before.
Not sure if thats any better but...
So when I run my current code, I only get two records. and thats not even the one thats in the user_cat table.
Any ideas?