Why won't it highlight the variable in the SELECT dropdown?
Posted: Sat Jul 03, 2010 5:07 am
Code: Select all
$cat = $_POST['cat'];
if ($cat == NULL) { $cat = 'Glass Beads Silver'; }
<form method='post' action='index.php?page=selector&menu=home&bid=$bid&brc=$brc'>You are in <select name='cat' class='selectordropdown'>";
$result = mysql_query ("SELECT DISTINCT category FROM products WHERE pause = 'off' AND (category = 'Glass Beads' || category = 'Glass Beads Silver' || category = 'Silver Charms') ORDER BY category");
while ($row = mysql_fetch_object($result))
{
if ($row->category == $cat) { $selected = "selected='selected' style='font-weight: bold'";}
elseif ($row->category != $cat) { $selected = "";}
echo "<option value='$row->category' $selected>$row->category</option>";
}
mysql_free_result($result);
echo "<input type='submit' value='Choose Category'></form>";The super-strange thing about this is - on my localhost server on my laptop, it will do it. Bearing in mind it's the second in the list, it will set that as the 'selected' item, but when I view it on a 'live' server both on Firefox and IE8, neither 'select' it.
Anyone know why? And if so, anyone so a solution?
S.