I’m creating a simple CMS which will allow staff to add new items to their (furniture sales) website.
I want them to be able to choose from the SET list of values for certain fields to make sure the items are displayed on the website correctly (ie to avoid typos etc).
I’ve spent a long time trawling forums and have so far got the below code. When it worked I could only get the drop down options from data held in the database, as opposed to the list of SET values I’d originally put in my database.
Eg under the Field called ‘Type’, I have assigned these values: set(‘table’,‘chair’,‘sideboard’,‘dresser’,‘winerack’,‘bookcase’,‘mirror’,‘drawers’,‘chests’,‘display’,‘tvunit’,‘bedside’,‘bed’,‘wardrobe’,‘dressingtab’,‘blanketbox’,‘desk’,‘filingcab’,‘workstation’)
These are what I want displayed in the drop down, not just the five values of items already in there.
However my CMS page is now not displaying anything in the drop downs and I can’t figure out why not!
So my question is, firstly any ideas what’s wrong with my code? And secondly, how to I populate the drop downs with the SET values?
Many thanks in advance for your help!
I didn’t want to bore you, so the code below is just the bit that’s relevant to my question, rather than all the connection info and $POST php etc.
//This is in my php code at the top of my page
[php] $sql = mysql_query(“SELECT DISTINCT id, supplier, room, type, material, finish, bespoke, image FROM furniture ORDER BY ASC”);
while($row = mysql_fetch_assoc($sql))
{
$supp .= "<option value=\"{$row['supplier']}\">{$row ['supplier']}</option>";
$room .= "<option value=\"{$row['room']}\">{$row['room']}</option>";
$type .= "<option value=\"{$row['type']}\">{$row['type']}</option>";
$material .= "<option value=\"{$row['material']}\">{$row['material']}</option>";
$finish .= "<option value=\"{$row['finish']}\">{$row['finish']}</option>";
$bespoke .= "<option value=\"{$row['bespoke']}\">{$row['bespoke']}</option>";
}
[/php]
//This is within my html
[code]
<label for="supplier">Manufacturer</label>
<select name="supplier" id="supplier" title="<?php echo $row_add['supplier']; ?>" >
<? echo $supp; ?>
</select>
<label for="room">Room</label>
<select name="room" id="room" title="<?php echo $row_add['room']; ?>" >
<? echo $room; ?>
</select>
<label for="type">Type</label>
<select name="type" id="type" title="<?php echo $row_add['type']; ?>">
<? echo $type; ?>
</select>
<label for="material">Material</label>
<select name="material" id="material" title="<?php echo $row_add['material']; ?>">
<? echo $material; ?>
</select>
<label for="finish">Finish</label>
<select name="finish" id="finish" title="<?php echo $row_add['finish']; ?>">
<? echo $finish; ?>
</select>
<label for="bespoke">Can be made-to-measure?</label>
<select name="bespoke" id="bespoke" title="<?php echo $row_add['bespoke']; ?>">
<? echo $bespoke; ?>
</select>
<input type="Submit" name="Add" id="add" value="Add" />
<input name="date" type="hidden" id="hiddenField" value="<?php echo $todayis['date']; ?>">
<input type="hidden" name="MM_insert" value="form1" />
</form>[/code]