Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selecting values from diff page

Status
Not open for further replies.

riffy

Programmer
Mar 29, 2001
106
US
Guys,

Another question, hopefully someone can help me. I have to program a category search on the mysql database that the site is using. In the database, there are 2 tables, say for example cproduct and hproduct. Hproduct has alot of elements inside it and I want to perform a category search on them.
I have 2 pages. The first page is a drop down that lists the distinct product names of the elements in the table. The user selects one and then clicks on search and it should lead to the second page which lists all those products with that particular name.
My problem is that on the second page what do I say in the query??? How do I access that value of the option statement on page 1?...
One of the products in the table is MasterLine PAR-16 Halogen Lamps so I have that as my value in the option statement.
So when the user selects that and then clicks on search, the second page should list all the products with that name. Like I said I am having trouble calling that value in the query on the second page.
any suggestions???

i'm posting the code for page 1...

Code:
<body text=&quot;#000000&quot; leftmargin=0 marginwidth=0 marginheight=0 topmargin=0 bgcolor=&quot;#FFFFFF&quot;>
<table border=0 cellspacing=0 cellpadding=0 width=600>
 <tr>
  <td valign=&quot;top&quot; height=219> 
   <table width=600 border=0 cellspacing=0 cellpadding=0>
    <tr> 
     <td width=119><!--#include virtual=&quot;includes/leftnav.html&quot; --></td>
     <td width=481 valign=&quot;top&quot;><br>
      <form action=&quot;halogensearch.php&quot;>
      <table width=480 border=0 cellspacing=0 cellpadding=0>
       <tr>
	<td><font face=&quot;arial, helvetica, sans-serif&quot; size=2>Halogen Categories:</font></td>
	<td>
	 <select>
	  <option [b]value=&quot;MasterLine<sup>TM</sup> PAR-16 Halogen Lamps&quot;[/b]>MasterLine<sup>TM</sup> PAR-16 Halogen Lamps</option>
	  <option [b]value=&quot;MasterLine<sup>TM</sup> PAR-20 Halogen Lamps&quot;[/b]>MasterLine<sup>TM</sup> PAR-20 Halogen Lamps</option>
	  <option [b]value=&quot;MasterLine<sup>TM</sup> PAR-30S Short Neck Halogen Lamps&quot;[/b]>MasterLine<sup>TM</sup> PAR-30S Short Neck Halogen Lamps</option>
//more option statements, just provided first three
	 </select>
	</td>
       </tr>
       <tr>
	<td colspan=2 align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;search&quot;></td>
       </tr>
      </table>
      </form>
     </td>
    </tr>
   </table>
  </td>
 </tr>
</table>
</body>

and my code for page 2 is...
Code:
<table width=740 border=0 cellspacing=0 cellpadding=0>
 <tr>
  <td colspan=2><font face=arial size=3><b>The Results: </b></font></td>
 </tr>
<?
$sql = &quot;select id, productname from halogenproduct [COLOR=red]where what?[/color]&quot;;
$result = mysql_query($sql); 
while ($row = mysql_fetch_array($result)) {
 extract($row);                     
?>
 <tr>
  <td><font face=arial size=2><? print $id; ?></font></td>
  <td><font face=arial size=2><? print $productname; ?></font></td>
 </tr>
<?
}
?>
</table>

if anyone can help, it'll be much appreciated

thanks
arif
X-) s-)
 
It looks like you want to change your <option> code to something like:
[tt]
<select name=&quot;ProductCategory&quot;>
<option value=&quot;Category1&quot;>MasterLine<sup>TM</sup> PAR-16 Halogen Lamps</option>
<option value=&quot;Category2&quot;>MasterLine<sup>TM</sup> PAR-20 Halogen Lamps</option>
<option value=&quot;Category3&quot;>MasterLine<sup>TM</sup> PAR-30S Short Neck Halogen Lamps</option>
</select>
[/tt]

Then:
[tt]
<?
sql = &quot;select id, productname from halogenproduct where hcategory = $ProdcutCategory&quot;;
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
extract($row);
?>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top