Jump to content


Photo

Linking my select box?


  • Please log in to reply
2 replies to this topic

#1 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 12 August 2006 - 01:52 PM

Hi I have created a select box using the following script:
<form name="form1" method="post" action="">
          <?php 
	$query  = 'select pd_id, pd_name FROM tbl_product group by pd_name desc';
	$result = @mysql_query($query) or die('<p>Sorry, no data to edit...</p>');
           ?>
	<select name="pd_id" id="select4">
             <?php
	while($row=mysql_fetch_assoc($result)) {
	echo "\t<option value=\"" . $row['pd_id'] . '">' . $row['pd_name'] . ' </option>';
	}											?>

what this script does is call the products name from the database and put it in the select box. What I need it to do now is when the user clicks on the select product it will automatically link to the product information. the url of the products are arranged like the following: product 1: categories.php?c=0&p=1 & product 2: categories.php?c=0&p=2

Any help will be really good as im really stuck on this one.

thx

#2 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 12 August 2006 - 02:56 PM

try
<form name="form1" method="GET" action="categories.php">
<input type="hidden" name="c" value="0">
<?php 
	$query  = 'select pd_id, pd_name FROM tbl_product group by pd_name desc';
	$result = @mysql_query($query) or die('<p>Sorry, no data to edit...</p>');
?>
	<select name="p" id="select4" onchange="submit()">
	<option value="0">---</option> 
<?php
	while($row=mysql_fetch_assoc($result)) {
	echo "\t<option value=\"" . $row['pd_id'] . '">' . $row['pd_name'] . ' </option>';
	}	
?>
<input type="submit"></form>


#3 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 13 August 2006 - 03:26 PM

cheers mate helped me out a load :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users