By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

Sending drop down menu selection to another page

P: 3
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.  
Jul 14 '07 #1
Share this Question
Share on Google+
4 Replies


P: 3
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.  
Jul 14 '07 #2

Atli
Expert 5K+
P: 5,058
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.
Jul 15 '07 #3

P: 3
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.
Jul 15 '07 #4

code green
Expert 100+
P: 1,726
Well you need a database for a start
Jul 18 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.