Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Select from Database based on user select

12:08 am on Mar 23, 2011 (gmt 0)

Full Member

5+ Year Member

joined:Aug 3, 2010
posts: 243
votes: 0

I've got a contact form where users choose from two drop down menus, the values are purely numerical. When the user submits the form I'm trying to select more data using whatever option they have selected. In the email I am getting the number (id) but cannot retrieve the data I'm after.

Here's the select code:

//Vehicle Details
$getmakeqry = mysql_query("SELECT manufacturer_id, manufacturer_name FROM manufacturer WHERE manufacturer_id = '".$make."'") or die(mysql_error());;
$getmakerow = mysql_fetch_row($getmakeqry);
$getmakeresult = $getmakerow['manufacturer_name'];

$getmodelqry = mysql_query("SELECT model_id, model_name FROM model WHERE model_id = '".$model."'") or die(mysql_error());;
$getmodelrow = mysql_fetch_row($getmodelqry);
while($getmodelresult = mysql_fetch_row($getmodelrow))
$getmodel = $getmodelresult[1];

Here's the email body side of it:

$content = "$name has provided the following information:\n\n Email: $email\n Phone: $phone\n Make1: $make\n Make2: $getmakeresult\n Model1: $model\n Model2: $getmodel\n Message: $message\n\n--------------------------\n\n IP Address: $ip\n Referrer: $hr\n Host: $hst\n";

So make1 and model1 are working, they show the ID of whatever they've selected in the form but make2 and model2 show nothing.

Make & Model are populate using the following:

$make = $_POST['request_make'];
$model = $_POST['request_model'];

$make = stripslashes(strip_tags(trim($make)));
$model = stripslashes(strip_tags(trim($model)));

You'll probably notice I've different things in getting it to work but I'm stuck for ideas now.

Any help would be great.
8:58 pm on Mar 23, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Oct 3, 2007
votes: 0

the code you show is all code for make1 and model1. If you show the make2 and model2 code, maybe someone can help you.