Codeman0013 Posted September 13, 2006 Share Posted September 13, 2006 Hey guys, How would I make my page I have connect to a database using javascript dependent dropdowns? I have all the things I need to get the database working where it displays all the info in the database but I only want it to display based on what they select not all of it. Here is my page any help would be greatly appreciated. <?php require_once('Connections/conn_dj.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}mysql_select_db($database_conn_dj, $conn_dj);$query_rs_industry = "SELECT * FROM tbl_industry ORDER BY industry_name ASC";$rs_industry = mysql_query($query_rs_industry, $conn_dj) or die(mysql_error());$row_rs_industry = mysql_fetch_assoc($rs_industry);$totalRows_rs_industry = mysql_num_rows($rs_industry);mysql_select_db($database_conn_dj, $conn_dj);$query_rs_productcategory = "SELECT * FROM tbl_productcat ORDER BY tbl_productcat.productCat_name";$rs_productcategory = mysql_query($query_rs_productcategory, $conn_dj) or die(mysql_error());$row_rs_productcategory = mysql_fetch_assoc($rs_productcategory);$totalRows_rs_productcategory = mysql_num_rows($rs_productcategory);mysql_select_db($database_conn_dj, $conn_dj);$query_rs_product = "SELECT * FROM tbl_products ORDER BY tbl_products.products_name";$rs_product = mysql_query($query_rs_product, $conn_dj) or die(mysql_error());$row_rs_product = mysql_fetch_assoc($rs_product);$totalRows_rs_product = mysql_num_rows($rs_product);mysql_select_db($database_conn_dj, $conn_dj);$query_rs_outsidena = "SELECT * FROM intl_countries ORDER BY intl_countries.name";$rs_outsidena = mysql_query($query_rs_outsidena, $conn_dj) or die(mysql_error());$row_rs_outsidena = mysql_fetch_assoc($rs_outsidena);$totalRows_rs_outsidena = mysql_num_rows($rs_outsidena);mysql_select_db($database_conn_dj, $conn_dj);$query_rs_state = "SELECT * FROM tbl_states ORDER BY tbl_states.`state`";$rs_state = mysql_query($query_rs_state, $conn_dj) or die(mysql_error());$row_rs_state = mysql_fetch_assoc($rs_state);$totalRows_rs_state = mysql_num_rows($rs_state);?><!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><title>DICKEY-john Corporation | Distributors</title><link href="_lib/sub.css" rel="stylesheet" type="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta name="keywords" content="Distributor, Sales, Purchase, U.S., International" /><meta name="description" content="Enter your zip or postal code to find the DICKEY-john distributor nearest you." /></head><body><div id="black"> </div><div id="siteContainer"> <?php include("_inc/topNav.inc"); ?> <div id="headerContainer">Distributors</div> <div class="divContainer"><div class="horizDiv"></div><img src="/_img/divEnd.png" alt="div" height="16" width="4" align="right" /></div> <div id="contentContainer"> <div id="fullContainer"> <div id="stretchCrumbs"> <a href="/index.php">Home</a> » <a class="high" href="/distributors/">Distributors</a> </div> <h1>Distributors</h1> <p>Search for DICKEY-john distributers by specifying any combonation of the<br /> following classifications: industry, product category, product, and state.</p> <br /> <br /> <h2>North America</h2> <table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0"> <tr><td>Industry:</td><td> <select name="industry" id="center"> <option value="">Select an Industry...</option> <?php do { ?> <option value="<?php echo $row_rs_industry['industry_name']; ?>"><?php echo $row_rs_industry['industry_name']; ?></option> <?php } while ($row_rs_industry = mysql_fetch_assoc($rs_industry)); ?> </select></td></tr> <tr><td width="125">Product Category: </td> <td> <select name="prodcat" id="center"> <option value="">Select a product category...</option> <?php do { ?> <option value="<?php echo $row_rs_productcategory['productCat_name']; ?>"><?php echo $row_rs_productcategory['productCat_name']; ?></option> <?php } while ($row_rs_productcategory = mysql_fetch_assoc($rs_productcategory)); ?> </select></td></tr> <tr> <td>Product:</td> <td> <select name="prod" id="center"> <option value="">Select a product...</option> <?php do { ?> <option value="<?php echo $row_rs_product['products_name']; ?>"><?php echo $row_rs_product['products_name']; ?></option> <?php } while ($row_rs_product = mysql_fetch_assoc($rs_product)); ?> </select> </td></tr> <td>State:</td> <td> <select name="state" id="center"> <option value="">Select a state...</option> <?php do { ?> <option value="<?php echo $row_rs_state['state']; ?>"><?php echo $row_rs_state['state']; ?></option> <?php } while ($row_rs_state = mysql_fetch_assoc($rs_state)); ?> </select></td> </tr> <tr><td> </td><td><input class="PythonButton" type="submit" value="Find" name="{Button_Name}"></td></tr> </table> </form> <br /> <h2>Outside North America </h2> <table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0"> <tr><td> <select name="outna" id="center" onchange="java script:document.centerform.submit()"> <option value="">Select a country...</option> <?php do { ?> <option value="<?php echo $row_rs_ousidena['name']; ?>"><?php echo $row_rs_outsidena['name']; ?></option> <?php } while ($row_rs_outsidena = mysql_fetch_assoc($rs_outsidena)); ?> </select></td> </tr></td></tr> </table> </form> </div> </div><?php include("_inc/footer.inc"); ?></body></html><?phpmysql_free_result($rs_industry);mysql_free_result($rs_productcategory);mysql_free_result($rs_product);mysql_free_result($rs_outsidena);mysql_free_result($rs_state);?> Link to comment Share on other sites More sharing options...
pulpfiction Posted September 13, 2006 Share Posted September 13, 2006 This might help....http://www.plus2net.com/php_tutorial/php_drop_down_list.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now