I am trying to populate a dropdown list using <select><option> and on the selected option pass the values to another page. I have been trying a lot of things over the las two days and I have finally decided to go to the community for assistance. The data is displayed in the option box but I am bogged down when trying to pass the values to the next page. I am using post to capture the data.

The code I am trying to use at this is as follows, if you need any further info please let me know.

Thanks in advance

DJ

$query="SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name, vehicles.vehicles_year
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";

// read database values
$result = mysql_query ($query);
echo "<select name=vehicles_model value=''><option>Select your vehicle</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt

echo "<option value=$nt[vehicles_id]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";
/* Option values are added by looping through the array */
		echo $id = $nt['vehicles_id'];	
}

echo "</select>";// Closing of list box 

			
			$id = $nt['vehicles_id'];
			$name = $nt['manufacturer_name'];
			$model = $nt['vehicles_model'];
			echo "<form action=\"cat.php\" method=\"post\">\n";
			echo"<input type=\"hidden\" name=\"manufacturer_name\" value=\"$make\">";
			echo"<input type=\"hidden\" name=\"vehicles_model\" value=\"$model\">";
			echo"<input type=\"hidden\" name=\"vehicles_pointer\" value=\"$category_id\">";
			echo"<input type=\"submit\" value=\"Search\">\n";
			echo"</form>";
			echo $model;

Recommended Answers

All 25 Replies

Member Avatar for rajarajan2017

In cat.php write the code as below:

$model=$_POST['vehicles_model'];
echo $model;

Hi Rajarajan, should this code $model=$_POST; replace the below code?

Thanks

DJ

$id = $nt['vehicles_id'];
$name = $nt['manufacturer_name'];
$model = $nt['vehicles_model'];
Member Avatar for rajarajan2017

First check with the code of mine and tell me what you got as the output.

You simple cut your line 27

echo "<form action=\"cat.php\" method=\"post\">\n";

and place it at line no 8 that is before executing your query. your select-option must be the part of your form to post it to next page.

Hi all,

I am trying to populate a dropdown list using <select><option> and on the selected option pass the values to another page. I have been trying a lot of things over the las two days and I have finally decided to go to the community for assistance. The data is displayed in the option box but I am bogged down when trying to pass the values to the next page. I am using post to capture the data.

The code I am trying to use at this is as follows, if you need any further info please let me know.

This is the code in full. The below values are passed from the previous page category_id and make.


Thanks
DJ

<?php
//passed values from form
$category_id=$_GET['category_id'];
$make=$_GET['make'];
//$model=$_GET['model'];



//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_GET['category_id']));
$make=mysql_real_escape_string(stripslashes($_GET['make']));
//$model=mysql_real_escape_string(stripslashes($_GET['model']));

// Testing variables
//echo $category_id;
//echo $make;

require('includes/headerr.php');// Include header
include ('includes/config.php');//setting user host and password values

include ('includes/opendb.php');//connection to the database

//This counts the number of records found
$x=("SELECT COUNT(*)
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'")or die(mysql_error());

$result=mysql_query($x)or die(mysql_error());
$total_rows= mysql_fetch_row($result);
echo $total_rows[0]. ' results found';
echo "<br/>";
echo "<br/>";


$query="SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name, vehicles.vehicles_year
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";

echo "<form action=\"cat.php\" method=\"post\">\n";
// read database values
$result = mysql_query ($query);
echo "<select name=vehicles_model value=''><option>Select your vehicle</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt

echo "<option value=$nt[vehicles_id]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";
/* Option values are added by looping through the array */
		echo $id = $nt['vehicles_id'];	
}

echo "</select>";// Closing of list box 
			
			$id = $nt['vehicles_id'];
			$name = $nt['manufacturer_name'];
			$model = $nt['vehicles_model'];
			
			$id = $_POST['vehicles_id'];
			$name = $_POST['manufacturer_name'];
			$model = $_POST['vehicles_model'];
			
			echo"<input type=\"hidden\" name=\"manufacturer_name\" value=\"$name\">";
			echo"<input type=\"hidden\" name=\"vehicles_model\" value=\"$model\">";
			echo"<input type=\"hidden\" name=\"vehicles_pointer\" value=\"$id\">";
			echo"<input type=\"submit\" value=\"Search\">\n";
			echo"</form>";
			echo $model;
			echo $id;
			echo $name;

This is the destination page details with no values passed

<?php
//passed values from form
$category_id=$_POST['vehicles_pointer'];
$make=$_POST['manufacturer_name'];
$model=$_POST['vehicles_model'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['vehicles_pointer']));
$make=mysql_real_escape_string(stripslashes($_POST['manufacturer_name']));
$model=mysql_real_escape_string(stripslashes($_POST['vehicles_model']));
//Testing past output values
echo $category_id;
echo $make;
echo $model;

require('includes/headerr.php');// Include header
include ('includes/config.php');//setting user host and password values

include ('includes/opendb.php');//connection to the database

//This counts the number of records found
$x=("SELECT COUNT(*)
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and vehicles_model='$model' and manufacturer_name='$make'")or die(mysql_error());

$result=mysql_query($x)or die(mysql_error());
$total_rows= mysql_fetch_row($result);
echo $total_rows[0]. ' results found';
echo "<br/>";
echo "<br/>";

//echo $category_id;
echo $make;
//echo $model;

Is your problem solved? if not then please specify the problem or close this thread.

Hi Urtrived, what is not working is the values being passed in the form to the next page for processing the data. I have followed the advice already provided and it still is not working when the value outputs are tested in the destination page there is no outout.

I have included the two listings one from the origin page and the second is the destination page.

If you require any additional information please let me know

Thanks again inadvance

DJ

<?php
//passed values from form
$category_id=$_GET['category_id'];
$make=$_GET['make'];
//$model=$_GET['model'];



//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_GET['category_id']));
$make=mysql_real_escape_string(stripslashes($_GET['make']));
//$model=mysql_real_escape_string(stripslashes($_GET['model']));

// Testing variables
//echo $category_id;
//echo $make;

require('includes/headerr.php');// Include header
include ('includes/config.php');//setting user host and password values

include ('includes/opendb.php');//connection to the database

//This counts the number of records found
$x=("SELECT COUNT(*)
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'")or die(mysql_error());

$result=mysql_query($x)or die(mysql_error());
$total_rows= mysql_fetch_row($result);
echo $total_rows[0]. ' results found';
echo "<br/>";
echo "<br/>";


$query="SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name, vehicles.vehicles_year
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";

echo "<form action=\"cat.php\" method=\"post\">\n";
// read database values
$result = mysql_query ($query);
echo "<select name=vehicles_model value=''><option>Select your vehicle</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt

echo "<option value=$nt[vehicles_id]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";
/* Option values are added by looping through the array */
echo $id = $nt['vehicles_id']; 
}

echo "</select>";// Closing of list box 

$id = $nt['vehicles_id'];
$name = $nt['manufacturer_name'];
$model = $nt['vehicles_model'];

$id = $_POST['vehicles_id'];
$name = $_POST['manufacturer_name'];
$model = $_POST['vehicles_model'];

echo"<input type=\"hidden\" name=\"manufacturer_name\" value=\"$name\">";
echo"<input type=\"hidden\" name=\"vehicles_model\" value=\"$model\">";
echo"<input type=\"hidden\" name=\"vehicles_pointer\" value=\"$id\">";
echo"<input type=\"submit\" value=\"Search\">\n";
echo"</form>";
echo $model;
echo $id;
echo $name;

This is the destination page details with no values passed

<?php
//passed values from form
$category_id=$_POST['vehicles_pointer'];
$make=$_POST['manufacturer_name'];
$model=$_POST['vehicles_model'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['vehicles_pointer']));
$make=mysql_real_escape_string(stripslashes($_POST['manufacturer_name']));
$model=mysql_real_escape_string(stripslashes($_POST['vehicles_model']));
//Testing past output values
echo $category_id;
echo $make;
echo $model;

require('includes/headerr.php');// Include header
include ('includes/config.php');//setting user host and password values

include ('includes/opendb.php');//connection to the database

//This counts the number of records found
$x=("SELECT COUNT(*)
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and vehicles_model='$model' and manufacturer_name='$make'")or die(mysql_error());

$result=mysql_query($x)or die(mysql_error());
$total_rows= mysql_fetch_row($result);
echo $total_rows[0]. ' results found';
echo "<br/>";
echo "<br/>";

//echo $category_id;
echo $make;
//echo $model;

write following code in destionantion file, to check whether data is posted or not

echo "<pre>";
print_r($_POST);
echo "</pre>";

Hi Urtrivedi, when adding the above code the destination screen does not produce any output at all, the screen is blank, when I comment the code out, I get output.

Thanks again

DJ

when you run first page just view html source. check whether all hidden fields are set properly, are they getting values or not.

secondly. when you open destination page. what values you are missing or exactly what problem occur.

Hi Urtrivedi, orgin variables $category and $make are present in the origin page but are passed to the destination screen
even that they can be echoed out in the origin screen

<?php
//passed values from form
$category_id=$_GET['category_id'];//This variable is visible on this screen
$make=$_GET['make'];//This variable is visible on this screen

 
//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_GET['category_id']));
$make=mysql_real_escape_string(stripslashes($_GET['make']));

// Testing variables
echo $category_id;// visible out put here. This has been passed from previous screen
echo $make;      // visible out put here.   This has been passed from previous screen

// Select query
	$query="SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name, vehicles.vehicles_year
	FROM category as category
	JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
	JOIN products as products on products.products_id = vehicles.FK_products_ID
	JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
	WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";


//Start of form

 echo "<form action=\"cat.php\" method=\"post\">\n";

// start to read database values
	$result = mysql_query ($query);
	echo "<select name=vehicles-model value=''><option>Select your vehicle</option>";
// printing the list box select command
 
while($nt=mysql_fetch_array($result))
	{		//Array or records stored in $nt
 
		echo "<option value=$nt[vehicles_id]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";
		/* Option values are added by looping through the array */

		echo $id = $nt['vehicles_id']; // no output?
	}
 
echo "</select>";// Closing of list box 
 


$model = $nt['vehicles_model']; //Should this be capturing data from the highlighted red code?
 



$model = $_POST['vehicles_model'];  //Should this be capturing data from the highlighted red code?
 
  echo"<input type=\"hidden\" name=\"manufacturer_name\" value=\"$make\">";// this value is know in the page, but does not pass to next page
  echo"<input type=\"hidden\" name=\"vehicles_model\" value=\"$model\">";
  echo"<input type=\"hidden\" name=\"vehicles_pointer\" value=\"$category_id\">";// this value is know in the page, but does not pass to next page
  echo"<input type=\"submit\" value=\"Search\">\n";
  echo"</form>";

  echo $model; // no output here

  echo $category_id;//output here available
  echo $make;//output here available

This the destination page to capture the value. no output is echoed to the screen

<?php
//passed values from form

  $category_id=$_POST['vehicles_pointer'];
  $make=$_POST['manufacturer_name'];
  $model=$_POST['vehicles_model'];
 
//Sanitize input values
  $category_id=mysql_real_escape_string(stripslashes($_POST['vehicles_pointer']));
  $make=mysql_real_escape_string(stripslashes($_POST['manufacturer_name']));
  $model=mysql_real_escape_string(stripslashes($_POST['vehicles_model']));

//Testing past output values
  echo $category_id;
  echo $make;
  echo $model;

You remove line

echo"<input type=\"hidden\" name=\"vehicles_model\" value=\"$model\">";

becuase you alreay have <select name=vehicle_model> no need to have hidden field for it.


Please check the spelling of vehicle-model (that you hightligted in red). Use underscore(_) instead of hypen(-).

Hi Urtrivedi, I have changed some of the variables and I now get output in the destination for $make and $category_id.

But the form does not seem to capture the model(variable)in the select option.

Thanks in adavance

DJ

echo "<form action=\"cat.php\" method=\"post\">\n";

// start to read database values
	$result = mysql_query ($query);
	echo "<select name=model value=''><option>Select your vehicle</option>";
// printing the list box select command
 
while($nt=mysql_fetch_array($result))
	{		//Array or records stored in $nt
 
		echo "<option value=$nt[vehicles_id]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";
		/* Option values are added by looping through the array */

		echo $id = $nt['vehicles_id']; // no output?
	}
 
echo "</select>";// Closing of list box 
 


$model = $nt['model']; //Should this be capturing data from the highlighted red code?
 



$model = $_POST['model'];  //Should this be capturing data from the highlighted red code?
 
  echo"<input type=\"hidden\" name=\"make\" value=\"$make\">";// this value is know in the page, and does pass to next page
 // echo"<input type=\"hidden\" name=\"model\" value=\"$model\">";
  echo"<input type=\"hidden\" name=\"category_id\" value=\"$category_id\">";// this value is know in the page, and does pass to next page
  echo"<input type=\"submit\" value=\"Search\">\n";
  echo"</form>";

  echo $model; // no output here

  echo $category_id;//output here available
  echo $make;//output here available
			
*****************
This the destination capture code

<?php
//passed values from form
$category_id=$_POST['category_id'];
$make=$_POST['make'];
$model=$_POST['model'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id']));
$make=mysql_real_escape_string(stripslashes($_POST['make']));
$model=mysql_real_escape_string(stripslashes($_POST['model']));
//Testing past output values
//echo "<pre>";
  //print_r($POST);
//echo "</pre>";
echo $category_id;   // output yes
echo $make;   // output yes

echo $model;   // output no

Your code seems to be fine, I am not able to trace the problem.

just again try at the begining of you destionation page, SEE WHAT COMES.

echo "<pre>";
print_r($_POST);
echo "</pre>";

Hi Urtrivedi, The output is as below - the model data?

Thanks

David

Array
(
    [model] => 
    [make] => Alfa Romeo
    [category_id] => 2
)

Hi Urtrivedi, I just tried this code but to no output still

Thanks

David

echo '<option value="'.$nt['vehicles_id'].'">'.$nt['vehicles_model'].'</option>';

i think there is a problem in vehicle_id of you query. in first page. it is null,
YOu have selected vehicles_id column in your query. please check it.

Hi Urtrivedi, here is how the values are passed from the very first time the variables were first used.

<option value="options.php?category_id=2&make=Alfa Romeo">Alfa Romeo</option> 


//*******************

$_Get was used to capture this string on the next page

$category_id=$_GET['category_id'];// these values are used to check against the db
$make=$_GET['make'];

$query="SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";
 echo "<form action=\"cat.php\" method=\"post\">\n";

// start to read database values
	$result = mysql_query ($query);
	echo "<select name=model value=''><option>Select your vehicle</option>";
// printing the list box select command
 
while($nt=mysql_fetch_array($result))
	{		//Array or records stored in $nt
 
		echo '<option value="'.$nt['vehicles_id'].'">'.$nt['vehicles_model'].'</option>';
		/* Option values are added by looping through the array */

		echo $id = $nt['vehicles_id']; // no output?
	}
 
echo "</select>";// Closing of list box 
 


$model = $nt['model']; //Should this be capturing data from the highlighted red code?
 



$model = $_POST['model'];  //Should this be capturing data from the highlighted red code?
 
  echo"<input type=\"hidden\" name=\"make\" value=\"$make\">";// this value is know in the page, and does not pass to next page
 // echo"<input type=\"hidden\" name=\"model\" value=\"$model\">";
  echo"<input type=\"hidden\" name=\"category_id\" value=\"$category_id\">";// this value is know in the page, and does not pass to next page
  echo"<input type=\"submit\" value=\"Search\">\n";
  echo"</form>";

so is the problem where I am not extracting the data in the SQL query?

Hi Urtrivedi, I have added vehicles.vheicles_id in the SQL query below and the value is passed in the form. I now loose the DISTINCT on the SQL query that you solved for me a few days ago by removing the same. So i am unsure how to get that back?

Thanks again in advance

DJ

$query="SELECT DISTINCT vehicles.vehicles_model, vehicles.vheicles_id manufacturer.manufacturer_name FROM category as categoryJOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID JOIN products as products on products.products_id = vehicles.FK_products_ID JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";


Array
(
    [model] => 8
    [make] => Alfa Romeo
    [category_id] => 2
)

you may user master table only for listing vechicle id, Here you are joining so many tables, that is creating problem for you.

And I think i suggested you to remove year from the query.

Hi Urtivedi, is there a better way of reading all the data in the query? in the mean-time I will remove the year from query

thanks in advance

David

post you tables structure with sample data. or attach such file

Also tell you want vehcile_id or vehicle_model in next page.

Hi Urtrivedi, The output would ideally from the vehicles model so this value can be passed to the destination page

Thanks again

David

CREATE TABLE `vehicles` (
  `vehicles_id` int(11) NOT NULL auto_increment,
  `vehicles_model` varchar(30) NOT NULL,
  `vehicles_year` varchar(20) NOT NULL,
  `vehicles_engine_size` varchar(30) NOT NULL,
  `vehicles_fuel_type` varchar(25) NOT NULL default 'PETROL',
  `FK_manufacturer_ID` int(11) NOT NULL,
  `FK_category_ID` int(11) NOT NULL,
  `FK_products_ID` varchar(25) NOT NULL,
  PRIMARY KEY  (`vehicles_id`),
  KEY `FK_manufacturer_ID` (`FK_manufacturer_ID`),
  KEY `FK_category_ID` (`FK_category_ID`),
  KEY `FK_products_ID` (`FK_products_ID`)
) ENGINE=MyISAM

CREATE TABLE `products` (
  `products_id` varchar(25) NOT NULL,
  `products_price` varchar(35) NOT NULL,
  `products_ah_20hr` varchar(20) default NULL,
  `products_sae_cold_start` varchar(20) default NULL,
  `products_bench_amps` varchar(20) default NULL,
  `products_length` varchar(20) NOT NULL,
  `products_width` varchar(20) NOT NULL,
  `products_height` varchar(20) NOT NULL,
  `products_weight` varchar(20) NOT NULL,
  `products_layout` varchar(20) default NULL,
  `products_terminals` varchar(20) default NULL,
  `products_base_holddown` varchar(20) default NULL,
  `products_notes` varchar(20) default NULL,
  `products_ah_5hr` varchar(15) default NULL,
  `products_ah_cap` varchar(15) NOT NULL,
  `products_pulse_amps` varchar(15) default NULL,
  `products_reserve_capacity` varchar(15) default NULL,
  `products_Image` varchar(64) default NULL,
  `products_quantity` varchar(10) default '1',
  `products_last_modified` datetime default NULL,
  `products_date_added` datetime default NULL,
  `products_warranty` varchar(20) default '2',
  `products_other2` varchar(20) default NULL,
  `products_other3` varchar(20) default NULL,
  `products_other4` varchar(20) default NULL,
  `products_output_voltage` varchar(15) default NULL,
  PRIMARY KEY  (`products_id`),
  KEY `products_notes` (`products_notes`)
) ENGINE=MyISAM

CREATE TABLE `manufacturer` (
  `manufacturer_ID` int(11) unsigned NOT NULL auto_increment,
  `manufacturer_name` varchar(255) NOT NULL,
  PRIMARY KEY  (`manufacturer_ID`),
  UNIQUE KEY `manufacturer_name` (`manufacturer_name`)
) ENGINE=MyISAM

CREATE TABLE `category` (
  `category_id` int(11) NOT NULL auto_increment,
  `category_name` varchar(50) NOT NULL,
  PRIMARY KEY  (`category_id`)
) ENGINE=MyISAM

your query could be like following

SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name from ....

For option element use vehicle_model field, do not use vehicle_id for option value.

echo "<option value=$nt[vehicles_model]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";

Hi Urtrivedi, Thanks very much for your assistance on solving my problem and for sticking with me to a conclusion

The last seemed to resolve the issue.

For those who may have followed this, here is the final code

$query="SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name
FROM category as category
JOIN vehicles as vehicles on category.category_ID = vehicles.FK_category_ID
JOIN products as products on products.products_id = vehicles.FK_products_ID
JOIN manufacturer as manufacturer on manufacturer.manufacturer_ID = vehicles.FK_manufacturer_ID 
WHERE vehicles.FK_category_ID = '$category_id' and manufacturer_name='$make'";


//Start of form

 echo "<form action=\"cat.php\" method=\"post\">\n";

// start to read database values
	$result = mysql_query ($query);
	echo "<select name=model value=''><option>All vehicle</option>";
// printing the list box select command
 
while($nt=mysql_fetch_array($result))
	{		//Array or records stored in $nt
 echo "<option value=$nt[vehicles_model]>Model: $nt[vehicles_model]</option>";
		
		/* Option values are added by looping through the array */

	}
 
echo "</select>";// Closing of list box */
  

//Should this be capturing data from the highlighted red code?
 
 echo"<input type=\"hidden\" name=\"make\" value=\"$make\">";// this value is know in the page
 echo"<input type=\"hidden\" name=\"category_id\" value=\"$category_id\">";// this value is know in the page
  
  echo"<input type=\"submit\" value=\"Search\">\n";
  echo"</form>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.