I can read, submit and delete from databases fine, but I just wanted to read field data into a select/option box. I've tried everything I can think of, but still no luck.
I will be so gratefull if anyone could point out my probably simple mistake ...
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("customers",$db);
$result = mysql_query("SELECT * FROM products",$db);
$columns = mysql_num_fields($result);
try filling list box ...
for ($i = 0; $i < $columns; $i++)
{
echo mysql_result($result, $i, 'name');
echo "<form>";
echo "<select name = '\name\'>";
echo "<option value =",
mysql_result($result, $i, 'name'),"\name>";
echo "</option>";
}
echo "</select></form>";
what went wrong?
test data read correctly ... yep!
for ($i = 0; $i < $columns; $i++)
{
echo mysql_result($result, $i, 'name');
echo "<br>";
}
?>
I'm sure I'm not the only one to come accross this, and I hope the answer helps others too.
😕