Basically I have a select box with the values from a dataset, what I need to do is say select the one that is equal to the value of another field in the dataset. Here is the code, many thanks in advance for your help 🙂
<option value="<?php echo $row_menucats1['id'] ?> "
<?php
$cats1 = $row_menucats1['id'];
$cats2 = $row_options['sub_cat_id_link'];
if ($cats1 == '$cats2') {
echo 'selected'
}
?> >
There is a simple syntax error. You need a semicolon after your echo statement:
Also your if statement: if
($cats1 == '$cats2')needs to be:if ($cats1 == $cats2)The current way you have it, it is an actual string.
To turn on error reporting you can add:
error_reporting(E_ALL);.