Codeman0013 Posted September 20, 2006 Share Posted September 20, 2006 Hey guys this might be just a noob question but in my sql query for the database how do i set it to say like where industry = and then the id number from the url for its query? Link to comment Share on other sites More sharing options...
Cronthenoob Posted September 20, 2006 Share Posted September 20, 2006 $id = $_REQUEST['url_id'];then your query will be:SELECT industry FROM table WHERE id=$id Link to comment Share on other sites More sharing options...
Codeman0013 Posted September 20, 2006 Author Share Posted September 20, 2006 that didnt work grr i tried some more things this is really annoying lol here is my code <?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 WHERE industry = ".$_GET['industry_id']."";$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> <form name="distributers"> <table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0"> <tr><td>Industry:</td><td> <select name="industry" id="industry" onchange="document.distributers.value='industry';document.distributers.submit();" > <option value="">Select an Industry...</option> <?php do { ?> <option value="<?php echo $row_rs_industry['industry_id']; ?>"><?php echo $row_rs_industry['industry_name']; ?></option> <?php } while ($row_rs_industry = mysql_fetch_assoc($rs_industry)); ?> </select></td></tr> <tr><td>Product category:</td><td> <select name="prodcat" id="center" disabled> <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> <tr><td>Products:</td><td> <select name="product" id="center" disabled > <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> <tr><td>State:</td><td> <select name="state" id="center" disabled > <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...
Cronthenoob Posted September 21, 2006 Share Posted September 21, 2006 Well, the $_GET method pulls value from the URL. From the looks of it, you arent ever sending the industry_id to the URL. Unless I just can't read.I also noticed your form doesnt have a method or an action. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 21, 2006 Share Posted September 21, 2006 case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break;You forgot to add a break after case "long":try that! Link to comment Share on other sites More sharing options...
justsomeguy Posted September 21, 2006 Share Posted September 21, 2006 It looks like long and int are the same case. Long is typically a long integer. But the case should be commented to indicate that they meant to do that, so that someone else doesn't come along and try to put a break in there. That's called a fall-through, where one case falls through into the next case.If you want to see a great example of cases falling through in C, and also make your head explode at the same time, take a look at Duff's device. 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