lightnb
07-09-2006, 04:36 AM
I have the following code:
<html>
<body>
<?php
$host='localhost';
$name='my_username';
$pass='mypassword';
$dbn='mydatabase_name';
$db = mysql_connect($host, $name, $pass);
mysql_select_db($dbn, $db);
?>
<select name = "color_name" size="1" style="width:180px;">
<Option Value="not_set">Please Choose a Color:</option>
<?php
$select_string = "SELECT key, color_number, color_name FROM roscolux_color";
$sql = mysql_query($select_string);
echo(mysql_error());
while($r = mysql_fetch_assoc($sql)){
?>
<option value="<?php echo($r['key']); ?>"><?php echo($r['color_number']).' - '.($r['color_name']); ?></option>
<?php
}
?>
</select><br>
</form>
</body>
</html>
It works fine, until I try to make the 'key' field from the database the value of the option. If I replace the 'key' field with a different field, it works fine. Any ideas why this field is behaving strangely?
Thanks,
Nick
<html>
<body>
<?php
$host='localhost';
$name='my_username';
$pass='mypassword';
$dbn='mydatabase_name';
$db = mysql_connect($host, $name, $pass);
mysql_select_db($dbn, $db);
?>
<select name = "color_name" size="1" style="width:180px;">
<Option Value="not_set">Please Choose a Color:</option>
<?php
$select_string = "SELECT key, color_number, color_name FROM roscolux_color";
$sql = mysql_query($select_string);
echo(mysql_error());
while($r = mysql_fetch_assoc($sql)){
?>
<option value="<?php echo($r['key']); ?>"><?php echo($r['color_number']).' - '.($r['color_name']); ?></option>
<?php
}
?>
</select><br>
</form>
</body>
</html>
It works fine, until I try to make the 'key' field from the database the value of the option. If I replace the 'key' field with a different field, it works fine. Any ideas why this field is behaving strangely?
Thanks,
Nick