Jump to content

list/menu sql search


marmalade

Recommended Posts

hi guys

i try to develop a bus ticket service,i created all necessary dbs and one of db includes departure point,destination point date time prices etc.

i can show all informations in one page

here is a code

first mysql connect

<?php require_once('Connections/Database.php');
mysql_select_db($database_Database, $Database);
$query_temp = "SELECT number,Dept, Dest, datetime FROM ".$bustable;
$result = mysql_query($query_temp, $Database) or die(mysql_error());
if (mysql_num_rows($result) == 0) { echo "no record"; exit; } ?>

 

and for the journeys

 

<?php while ($row = mysql_fetch_assoc($result)) {
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})", $row['datetime'], $regs); ?>
    <a href="info.php?bus=<?php echo $row['number']; ?>"><?php //echo $row['number']; ?>
<?php echo $row['Dept']; ?><?php echo $row['Dest']; ?> - 
<?php /*echo "$regs[3]/$regs[2]/$regs[1] $regs[4]:$regs[5]"; */?><?php echo $row['datetime']; ?></a><BR>
<?php } ?>

so my problem is

i can make visitors to buy a ticket succesfully but i want to make it easy  so  i want that a visitor should select the departure and destination point using a list/menu -one for departure point one for destination- and when he/she clicks the button,page give him/her the available journeys.

for example i have a record like ny to la at 11.00 pm on 01.01.2009 and at 12.00 pm on 02.01.2009

so if a visitor using list/menu and choose departure ny and destination la,it must be show two records.

but if there isn't any record,it prints "no record".any helps will be useful to me

 

Link to comment
https://forums.phpfreaks.com/topic/139077-listmenu-sql-search/
Share on other sites

Is the destination dependent of the departure point?  Or do you just want to list all of them and then see if they match?

 

the first you said is awesome for this script but it is more difficult than the other i think,but if u can help me about this i prefer this one,but if u can't,don't bother, list all and see if they match is enough for me

Link to comment
https://forums.phpfreaks.com/topic/139077-listmenu-sql-search/#findComment-727467
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.