Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2007, 02:05 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dyamic Drop Down Box

I have a drop down list that is being populated by a MySQL db table, I am trying to display the information and want to have the drop down list populated with the user's choice selected with the rest of the list. Please help. Thanks

JE

 
Old August 16th, 2007, 11:39 PM
Authorized User
 
Join Date: Mar 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to cyber_kaley20 Send a message via AIM to cyber_kaley20 Send a message via Yahoo to cyber_kaley20
Default


 drop down list populated by a MySQL db table


<?php require_once('Connections/test.php'); ?>



<?php
mysql_select_db($database_test, $test);
$query_Recordset1 = "SELECT * FROM tour_data";
$Recordset1 = mysql_query($query_Recordset1, $test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>







<form name="form1" method="post" action="">
    <label>
      <select name="select">
        <?php
do {
?>
        <option value="<?php echo $row_Recordset1['tour_title']?>"<?php if (!(strcmp($row_Recordset1['tour_title'], "3"))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['tour_title']?></option>
        <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
      $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
    </select>
    </label>
  </form>

Escaler





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Won't Drop Down sjf905 C# 0 January 13th, 2007 12:09 AM
drop down box selected value crmpicco HTML Code Clinic 1 March 31st, 2005 09:56 AM
Drop down Box NomAnor Classic ASP Basics 2 March 29th, 2004 12:21 PM
Drop down box format julitin Classic ASP Basics 1 November 6th, 2003 12:02 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.