I've been searching all day for an answer. I've seen lots of questions but no really concrete answers. I have a database of products, with 1 Table (Products) and column 1 is "Product" and lists all the model numbers. I want a dropdown menu that will allow me to choose the model, then select Submit and show the details of that model on the page. Right now I'm just trying to get the models to show up in the dropdown and it is just blank.
Here's the code
<?php
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$result = mysql_query "SELECT 'Product1' FROM Products");
mysql_select_db('database_products');
$retval = mysql_query( $result, $conn );
echo "<form method=post action=$PHP_SELF>n
<select name = Product> n";
while ($myrow = mysql_fetch_array($result))
#each entry in the array is then displayed in a dropdown menu according to it's title. The field ID is not displayed on the screen but its important because changes will be made to these entries based on their ID ...
{
printf("<option value= %s> - %s n", $myrow["Product"]);
}
echo "</select> n <input type=submit name=modify value=modify>n
</form>";
?>
I'm sure I've done something stupid because I really don't grasp this all too well. Any thoughts?
Thank you!
Aucun commentaire:
Enregistrer un commentaire