Hi all :), at the moment im programming a drop down list of a petstore and going through chapters from the php my dummies book. I show you my example.
<?php
// Program name: buildselect.php
// Description: Program builds a selection list from databse
require_once("config.php");
$query = "SELECT DISTINCT * petType FROM Pet ORDER BY petType'";
$result= mysqli_query($cxn, $query)
or die ("Couldn't execute query.");
?>
<html>
<head>
<title>Pet types</title>
<body>
<form action='processform.php' method='POST'>
<select name='petType'>
<?php
while($row = mysqli_fetch_assoc($result))
{
extract($row);
echo"option value='petType'>$petType</option>\n";
}
?>
</select>
<input type='submit' value='Select Type of Pet' />
</form>
</body>
</head>
My unfortunate issue is that the message displays "Couldn't execute query" that comes from the die message and if i remove the $query, £result and the die on the top, it displays the drop down selection list and a button next to it. The aim is when writing this in php it saves users typing in categories manaully using option tags so you won't need to re-add categories when you have done so in the database (sorry if im waffling)
Hope I made sense and hope you guys can solve this problem
thank you :D