Form help


#1

I’m trying to create a form where I can submit info that will go into my database. My problem here is that it picks out the carmake but in my case because I have Honda more than once it comes up more than once.

IE the O is a check mark in the web site

O Ford O Honda OHonda O Honda ( I just want Honda all carmakes to come up once)

<?php ?> Car Makes <?php include("misc.inc"); $connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database");

/* gets pet types from PCarMake table in alphabetical order */
$query = “SELECT CarMake FROM ALL_ITEMS ORDER BY CarMake”; // 21
$result = mysql_query($query)
or die (“Couldn’t execute query.”);

/* Display text before form */
echo "

Select the category for the pet you are adding.

If you are adding a pet in a category that is not listed, choose New Category and type the name and description of the category. Press Submit Category when you have finished selecting an existing category or typing a new category.n";

/* Create form containing selection list */
echo “n”;
echo “

n”;
echo “”;
$counter=0; // 38
while ($row = mysql_fetch_array($result)) // 39
{
extract($row);
echo "n”; // 48
$counter++; // 49
}
echo “

<input type=‘radio’ name=‘category’ value=’$CarMake’"; // 43
if ($counter == 0) // 44
{
echo “checked”;
}
echo “>$CarMake
n”;

include(“NewCat_table.inc”); // 53

echo “

n”;
echo “n”;
?>


#2

Have you tried using DISTINCT?

SELECT DISTINCT CarMake FROM ALL_ITEMS ORDER BY CarMake

This should prevent rows being fetched that have the same name.


#3

Thanks the Distinc function worked, so now I have to try to get the rest of it to work.