forwardlookguy 0 Newbie Poster

Hello, I have a problem that someone can hopefully help me with. I have a page where Make, Year and Model menus are dynamically created via mysql. Upon selection, the user presses submit and those values are fed to the database where the production numbers for say, a 1958 Plymouth Belvedere are displayed. The menus work fine. I just can't figure out how to feed the menu values into the database to display the production numbers.

Here's the code for the first page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />

<title>Classic Decoder</title>
<meta http-equiv="content-type" content="text/html; charset=us-ascii" />
</head>

<body>

<link rel="stylesheet" href="includes/background.css" type="text/css" />
<?php require("includes/header.css"); ?>

<script language="javascript" type="text/javascript">
<!--

function text(txt) {
   window.status = txt;
}
// -->
</script>

<script type="text/javascript">
function AjaxFunction(id)
{
var httpxml;
try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
		  try
   			 		{
   				 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
    				}
  			catch (e)
    				{
    			try
      		{
      		httpxml=new ActiveXObject("Microsoft.XMLHTTP");
     		 }
    			catch (e)
      		{
      		alert("Your browser does not support AJAX!");
      		return false;
      		}
    		}
  }
function stateck() 
    {
    if(httpxml.readyState==4)
      {
document.getElementById("Makesid").innerHTML=httpxml.responseText;

      }
    }
	var url="dd.php";
url=url+"?id="+id;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
  }
</script>

<p>


<form name="selection">
Please select a make: <select name=cat onchange="AjaxFunction(this.value);">
<option value=''>Select One</option>

<?php


require "includes/dbconnect.php";// connection to database 
$q=mysql_query("select * from Makes order by name");
while($n=mysql_fetch_array($q)){
echo "<option value=$n[id]>$n[name]</option>";

}

?>
// Close database connection.
mysql_close();

?>
</select>

<div id="Makesid"></div>

</form>

<p>
<form action="productionfigures.php" method="post">
<input type="Submit" value="Submit" name="Submit">
</p>


<hr />

Note: The Rambler name was used from 1957 - 1969; meanwhile, the American Motors (AMC) name was incorporated in 1966 and used through 1980.
</p>
</body>
</html>

And here's the code for the page where the second and third menus are populated:

<html>
<head>

<link rel="stylesheet" href="includes/background.css" type="text/css" />
</head>

<body>
<p>

the year:


<?php

$id=$_GET['id'];
require "includes/dbconnect.php";
$q=mysql_query("select distinct yearname from Years where id='$id' order by yearname");
echo mysql_error();
echo "<select name=subcat>";
while($nt=mysql_fetch_array($q)){
echo "<option value='$nt[id]'>$nt[yearname]</option>";

}
echo "</select>";

?>

<br />
<br />

and the model:

<?php


$id=$_GET['id'];
require "includes/dbconnect.php";
$q=mysql_query("select * from Models where id='$id' order by modelname");
echo mysql_error();
echo "<select name=subcat>";
while($nt=mysql_fetch_array($q)){
echo "<option value='$nt[modelname]'>$nt[modelname]</option>";

}
echo "</select>";

?>

</p>
</body>
</html>

Could someone help me create the code for this? And would it go on the first page or the second?

Thanks a lot for any help,
Arthur Ash III

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.