I have the following code
<option value="">Chose a category</option>
<option value="">----------------------</option>
<? mysql_connect("localhost");mysql_select_db(db_name);
$result1=mysql_query("SELECT categoryid, category FROM categories");
while($row=mysql_fetch_assoc($result1)) {
if($row['categoryid']==$post_element['categoryid']) {
echo "<option value=".$row['categoryid']."selected>".$row['category']."</option>";}
else {echo "<option value=".$row['categoryid'].">".$row['category']."</option>";}}?>
</select>
It doesn't work, i am retrieving all the fields of a table, one of them is the categoryid, i wanna match the categoryid from the table categories and from table post in order to one element from the list to be selected
Am i on the right way?