Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Select from Database based on user select


LinusIT - 12:08 am on Mar 23, 2011 (gmt 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.


Thread source:: http://www.webmasterworld.com/php/4286040.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com