Hi everyone
I have a website for a music shop using a MYSQL database of products. The make and model colums are indexed. One page in the site allows admin users to modify product details. It has a drop down menu that is populated from the database like so:
$sql = "SELECT pid, make, model, new FROM products order by make, model";
// Returns result
$mysql_result=mysql_query($sql,$connection);
echo"Query run";
// Counts the number of rows
$num_rows=mysql_num_rows($mysql_result);
// Tests if the database is empty
if ($num_rows == 0) {
echo"<CENTER>You need to add some products first!</CENTER>";
}
// If there are records....
else {
// Form to pick the product to be ammended
echo "<FORM method=post action=\"view_record.php\">";
echo "Please select a product <BR>";
echo "<select name=\"record\">";
// Loop to populate the menu
while ($row=mysql_fetch_array($mysql_result)) {
$pid=$row["pid"];
$make=$row["make"];
$model=$row["model"];
$new=$row["new"];
// Display options in the pulldown box
echo "<option value=\"$pid\">$new $make $model</option>";
} // end while
echo "</select>";
} // end else
echo "<BR><BR>";
echo "<input type=\"submit\" value=\"View the record\"></FORM>";
mysql_close($connection);
The problem is that sometimes this menu will be populated really quickly. Other times, the page will be blank for ages, and when I hit stop in the browser, only a few records are shown in the drop down. There are currently 124 products in the database.
What is going on?
Many thanks
Daniel