| | |
pass php variables to mysql database
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 23
Reputation:
Solved Threads: 0
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:
And here's the code for the page where the second and third menus are populated:
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
Here's the code for the first page:
MySQL Syntax (Toggle Plain Text)
<!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:
MySQL Syntax (Toggle Plain Text)
<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
![]() |
Similar Threads
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- How to import excel file data to mysql database (ASP.NET)
- php results from form - stuck (PHP)
- Can a text link pass php variables? (PHP)
- submiting info into a database for retrieval! (PHP)
- PHP/Mysql (PHP)
- question about connecting odbc to sql through php script (PHP)
- Php newsletter error (PHP)
Other Threads in the MySQL Forum
- Previous Thread: Reading OUT param in stored procedure
- Next Thread: What to fetch second highest marks?
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





