TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-04-2008, 11:02 PM   #1 (permalink)
The Visitor
 
worldop's Avatar
 
Join Date: Dec 2008
Location: UK
Posts: 2
Thanks: 1
worldop is on a distinguished road
Default drop downs from table data

Hello, I'm developing a booking system. I've got a database, with records such as( colon representing column break ):
Bristol : Newcastle
Bristol : Manchester
Manchester : Bristol
and so on, I'm trying to make drop down menu's for Departing City, and Destination City using <select><option> html. I'm getting duplicate drop-down options and im not sure how to display one of each of the departing/destination records, Also another thing I don't know how to do is, only display the corresponding Destination: e.g.
if the Departing City is Bristol, then only the destinations from Bristol should appear in the second drop-down.

Here is my code so far, if anyone could help it would be appreciated, thanks.
php Code:
$Query = "SELECT DISTINCT DepartingFrom FROM flights";
$RunQuery = mysqli_query($dbc, $Query) or trigger_error("Query: $Query\n<br />MySQL Error: " . mysqli_error($dbc));


if(mysqli_num_rows($RunQuery) > 0){
    echo '<h1>Book your flight here</h1><br />
            <b>Airport to fly from:</b>'
;
    echo '<select>';
    while($Row = mysqli_fetch_array($RunQuery)){
            echo '<option>' . $Row['DepartingFrom'] . '</option>';
        } /* end of while loop */         
            echo '</select><br />';
            echo '<b>Airport to Fly to:</b>
            <select>'
;
            $Query = "SELECT ArrivalAt FROM flights";
            $RunQuery = mysqli_query($dbc, $Query) or trigger_error("Query: $Query\n<br />MySQL Error: " . mysqli_error($dbc));
            while($Row = mysqli_fetch_array($RunQuery)){
                echo'<option>' . $Row['ArrivalAt'] . '</option>';
            } /* end of while loop */
            echo'</select>';
        echo '<br />';
   
} /* end of if statement - add error if there were no rows in flights */
__________________
If something bad is going to happen, it will.

Last edited by worldop : 12-04-2008 at 11:16 PM. Reason: Solved the first bit of the problem by using the "DISTINCT" keyword for SQL
worldop is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem getting data on the html table.... jetnet1 General 2 11-24-2008 06:55 PM
Loading data form table to table? code_junkie Absolute Beginners 5 11-06-2008 03:34 PM
Creating a table from loaded data benton General 5 04-20-2008 11:48 AM
Tips: PHP security Village Idiot Tips & Tricks 22 11-23-2007 11:17 PM


All times are GMT. The time now is 07:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design