Re: Dynamic menu not passing value to PHP?
[email protected] ("Dennis Martin Ong") Tue, 17 Jun 2003 05:44:26 +0800
| Newsgroups | php.lang |
|---|---|
| Message-ID | <[email protected]> |
Sorry, posted this to the wrong mail group.....my apologies... Dennis "Dennis Martin Ong" <[email protected]> wrote in message news:[email protected]... > Hi, > > I'm trying to create a page where a user can choose to view products by > category by selecting a drop down menu or he can choose to do a search > against the item name. The script seems to work but I'm puzzled cos the > mysql query seems to be querying all the category while it is suppose to > match it via the selected option value from the dynamic menu. Is there > something I've missed out cos it seems like the $sltCat which is suppose to > pass the selected option value when the form is submitted is not passing the > correct value, resulting in the mysql query throwing out all the info when > it is supposed to only throw info when category match $sltCat.. > > Thanks in advance for the help > > Dennis > > <?php require_once('Connections/connPyramid.php'); ?> > <?php > mysql_select_db($database_connPyramid, $connPyramid); > $query_rsMenu = "SELECT category FROM category ORDER BY category ASC"; > $rsMenu = mysql_query($query_rsMenu, $connPyramid) or die(mysql_error()); > $row_rsMenu = mysql_fetch_assoc($rsMenu); > $totalRows_rsMenu = mysql_num_rows($rsMenu); > > $maxRows_rsCat = 10; > $pageNum_rsCat = 0; > if (isset($HTTP_GET_VARS['pageNum_rsCat'])) { > $pageNum_rsCat = $HTTP_GET_VARS['pageNum_rsCat']; > } > $startRow_rsCat = $pageNum_rsCat * $maxRows_rsCat; > > mysql_select_db($database_connPyramid, $connPyramid); > $query_rsCat = "SELECT * FROM inventory WHERE category='$sltCat' OR > item_name LIKE '%$txtSearch%'"; > $query_limit_rsCat = sprintf("%s LIMIT %d, %d", $query_rsCat, > $startRow_rsCat, $maxRows_rsCat); > $rsCat = mysql_query($query_limit_rsCat, $connPyramid) or > die(mysql_error()); > $row_rsCat = mysql_fetch_assoc($rsCat); > > if (isset($HTTP_GET_VARS['totalRows_rsCat'])) { > $totalRows_rsCat = $HTTP_GET_VARS['totalRows_rsCat']; > } else { > $all_rsCat = mysql_query($query_rsCat); > $totalRows_rsCat = mysql_num_rows($all_rsCat); > } > $totalPages_rsCat = ceil($totalRows_rsCat/$maxRows_rsCat)-1; > ?> > > > <form name="frmProducts" method="post" action="products.php"> > <select name="sltCat" id="select" value> > <option value="None">None</option> > <?php > do { > ?> > <option value="<?php echo > $row_rsMenu['category']?>"><?php echo $row_rsMenu['category']?></option> > <?php > } while ($row_rsMenu = mysql_fetch_assoc($rsMenu)); > $rows = mysql_num_rows($rsMenu); > if($rows > 0) { > mysql_data_seek($rsMenu, 0); > $row_rsMenu = mysql_fetch_assoc($rsMenu); > } > ?> > </select> > <input type="text" name="txtSearch"> > <input type="submit" name="btnGo" value="Go..."> > <?php do { ?> > <?php echo ($row_rsCat['item_name']); ?> > <?php } while ($row_rsCat = mysql_fetch_assoc($rsCat)); ?> > </form> > > > <?php > mysql_free_result($rsMenu); > > mysql_free_result($rsCat); > ?> > > > > >