Connecting Tech Pros Worldwide Help | Site Map

Sending drop down menu selection to another page

Newbie
 
Join Date: Jul 2007
Posts: 3
#1: Jul 14 '07
Here is what I have done:
Created a page with a drop down menu listing names of builders retrieved from a mysql database containing contact info for client builders.
What I need to do, and so far have been stumped, is this:
When a builder name is selected from the drop down, I need to have the selected builders record, (name, address, etc) listed in a table on another page.
The new page would be called viewbuilder.php

Will someone PLEASE help me with the code to accomplish this??
Here is the code for the page having the drop down menu. As you can see I am using Dreamweaver.

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('Connections/btest.php'); ?>
  2. <?php
  3. mysql_select_db($database_btest, $btest);
  4. $query_Recordset1 = "SELECT * FROM builder ORDER BY bname ASC";
  5. $Recordset1 = mysql_query($query_Recordset1, $btest) or die(mysql_error());
  6. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  7. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  8. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  12. <title>Untitled Document</title>
  13. </head>
  14.  
  15. <body>
  16. <form id="form1" name="form1" method="post" action="">
  17.   builder
  18.     <select name="select">
  19.       <option value="?">-Please Select-</option>
  20.       <?php
  21. do {  
  22. ?>
  23.       <option value="<?php echo $row_Recordset1['bname']?>"><?php echo $row_Recordset1['bname']?></option>
  24.       <?php
  25. } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  26.   $rows = mysql_num_rows($Recordset1);
  27.   if($rows > 0) {
  28.       mysql_data_seek($Recordset1, 0);
  29.       $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  30.   }
  31. ?>
  32.   </select>
  33. </form>
  34. </body>
  35. </html>
  36. <?php
  37. mysql_free_result($Recordset1);
  38. ?>
  39.  
Newbie
 
Join Date: Jul 2007
Posts: 3
#2: Jul 14 '07

re: Sending drop down menu selection to another page


Sorry. I had forgotten to add a submit button.
This is the code with the submit button added.

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('Connections/btest.php'); ?>
  2. <?php
  3. mysql_select_db($database_btest, $btest);
  4. $query_Recordset1 = "SELECT * FROM builder ORDER BY bname ASC";
  5. $Recordset1 = mysql_query($query_Recordset1, $btest) or die(mysql_error());
  6. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  7. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  8. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  12. <title>Untitled Document</title>
  13. </head>
  14.  
  15. <body>
  16. <form id="form1" name="form1" method="post" action="">
  17.   builder
  18.     <select name="select">
  19.       <option value="?">-Please Select-</option>
  20.       <?php
  21. do {  
  22. ?>
  23.       <option value="<?php echo $row_Recordset1['bname']?>"><?php echo $row_Recordset1['bname']?></option>
  24.       <?php
  25. } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  26.   $rows = mysql_num_rows($Recordset1);
  27.   if($rows > 0) {
  28.       mysql_data_seek($Recordset1, 0);
  29.       $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  30.   }
  31. ?>
  32.   </select>
  33.     submit
  34.     <input type="submit" name="Submit" value="Submit" />
  35. </form>
  36. </body>
  37. </html>
  38. <?php
  39. mysql_free_result($Recordset1);
  40. ?>
  41.  
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,746
#3: Jul 15 '07

re: Sending drop down menu selection to another page


Hi, cctxman1942, and welcome to TSDN!

What I would do, is not send all the info from the 'select' page to the 'display' page. I would just send the ID of the data I wanted displayed, and then retreive the data from the database when I want to display it.
Newbie
 
Join Date: Jul 2007
Posts: 3
#4: Jul 15 '07

re: Sending drop down menu selection to another page


Quote:

Originally Posted by Atli

Hi, cctxman1942, and welcome to TSDN!

What I would do, is not send all the info from the 'select' page to the 'display' page. I would just send the ID of the data I wanted displayed, and then retreive the data from the database when I want to display it.


Thank you, Atli for your response.
Please accept my apology for my ignorance, but how do you do that?
Thanks again.
code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,078
#5: Jul 18 '07

re: Sending drop down menu selection to another page


Well you need a database for a start
Reply