Selection list

I’m trying to make a selection list where they would pick the type of model they want and that goes into the query and would come up on the page, now the form is just there and nothing happens ? Here is the code I have.

$query = “SELECT * FROM ALL_ITEMS where carmodel=’$carmodel’”;
$result = mysql_query($query)
or die (“Couldn’t execute query.”);

/* Display results in a table */

echo "

n";
echo “Civic”;
echo “Accord”;

echo “n”;

while ($row = mysql_fetch_array($result))
{
extract($row);
echo “$carmodeln”;
}
echo “n”;
echo "
n";

echo "<font size=‘10’color=’#000080’ face=‘Monotype Corsiva’>All Honda’s
";
echo “

”;
echo “”;
echo "";

echo “

”;
echo “”;
echo "";

echo “

”;
echo “
<font size=‘4’color=’#000080’>Cars/Autos <font size=‘4’color=’#000080’>Trucks/Camions Boats/Bateaux Motorcycles/Motocyclettes
<font size=‘4’color=’#000080’>RV’s/Roulottes <font size=‘4’color=’#000080’>Houses/Maisons ATV's Vans/Fourgonettes
”;

echo “<table cellspacing='5’border=‘0’>”;
echo “


”;
while ($row = mysql_fetch_array($result))
{
extract($row);
  echo "
       <td width='10%'valign='top'><b>ID:$ID</b></td>n
	<td width='25%'><a HREF='http://www.privatesalenb.com/images/$PICS' ><img src='/images/$PICS' width='200'height='140'></a> </td>n
	<td valign='top' width='55%'><b>Model: $CARMODEL </b><br> $DESCRIPTION</td>n
n n Click on picture to view larger Contact: $ContactInfon
       </tr>n";
 echo "<tr><td colspan='4'><hr></td></tr>n";

}
echo “n”;
?>

Just a quick suggestion, try not to use PHP to output HTML text. It’ll slow the process and is more prone to errors (especially when considering " )

Try again, but stop PHP like this ?> and continue it like this <?

for instance…

<? Some PHP code insert loop ?>

boring html

<? close loop Continue code ?>

Simple :P

after you make the few alterations miles suggested, please repost your code using either the bracket ([) php/code bracket (]) or use the code button above. this will maintain the indention of your code so it is much easier to read and figure out what is going wrong.

Here is my code with the code button, it goes to Processform.php and doesn’t do anything ?

Here is the URL

[code]

Honda Page <?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"); $carmake = "Honda"; $query = "SELECT * FROM ALL_ITEMS where carmake='$carmake'"; $result = mysql_query($query) or die ("Couldn't execute query."); /* Display results in a table */ echo "All Honda's
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Cars/Autos Trucks/Camions Boats/Bateaux Motorcycles/Motocyclettes
RV's/Roulottes Houses/Maisons ATV's Vans/Fourgonettes
"; echo ""; echo ""; while ($row = mysql_fetch_array($result)) { extract($row); echo " n n n n n n n"; echo "n"; } echo "

ID:$ID Model: $CARMODEL
$DESCRIPTION
Click on picture to view larger Contact: $ContactInfo

n"; ?>


<font size=‘6’color=’#000080’ face=‘Monotype Corsiva’>Back to Main Page

[/code]http://www.privatesalenb.com/php/honda21test.php

[code]
$query = “SELECT * FROM ALL_ITEMS where carmake=’$carmake’”;
// try using the back tick rather then the single quote
$query = “SELECT * FROM ALL_ITEMS where carmake=$carmake”;

while ($row = mysql_fetch_assoc($result))
{
echo "
<td width=‘10%‘valign=‘top’>ID:{$row[‘ID’]}n

<a HREF=‘http://www.privatesalenb.com/images/{$row[‘PICS’]}’ ><img src=’/images/{$row[‘PICS’]}’ width='200’height=‘140’> n
Model: {$row[‘CARMODEL’]}
{$row[‘DESCRIPTION’]}n n n Click on picture to view larger Contact: $ContactInfon
       </tr>n";
 echo "<tr><td colspan='4'><hr></td></tr>n";

} [/code]

Ok what I did is change the mysql_fetch_array into mysql_fetch_assoc. This returns the results as an associative array where the keys are the names of the table columns (assumption that the all caps are the column names). The curlybraces tell the parser (I think the parser no the compiler) that the variable names within them are to be taken as 1 value.

Sponsor our Newsletter | Privacy Policy | Terms of Service