Hi,

I have the following script.  What I want is that when I select the
country the corresponding cities should only be listed in the second
dropdown box.  Can some one guide me.  Right below is my table
structure. 


$searchStmt = "select name from airlines group by name order by name" ;
#$searchStmt1 = "select * from destinazione order by name" ;
$searchStmt1 = "select * from country order by country";
$searchStmt2 = "select name from airport group by name order by name" ;
$searchStmt3 = "select * from city order by city";



// connect to the db

if (!($link = mysql_pconnect($db_server, $db_login, $db_passwd))){
   DisplayErrMsg(sprintf("internal error %d:%s\n",
      mysql_errno(), mysql_error()));
   exit() ;
}

// Selct the db

if (!mysql_select_db($db, $link)) {
   DisplayErrMsg(sprintf("Error in selecting %s db", $db)) ;
   DisplayErrMsg(sprintf("error:%d %s", mysql_error($link),
mysql_error($link))) ;
   exit();
}

// Execute the Statement for compagnia_aerea
if (!($result = mysql_query($searchStmt, $link))) {
   DisplayErrMsg(sprintf("Error in executing %s stmt", $searchStmt));
   DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link),
mysql_error($link)));
   exit();
}

// Execute the Statement for destinazione/Country
if (!($result1 = mysql_query($searchStmt1, $link))) {
   DisplayErrMsg(sprintf("Error in executing %s stmt", $searchStmt1));
   DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link),
mysql_error($link)));
   exit();
}

// Execute the Statement for airports
if (!($result2 = mysql_query($searchStmt2, $link))) {
   DisplayErrMsg(sprintf("Error in executing %s stmt", $searchStmt2));
   DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link),
mysql_error($link)));
   exit();
}
// Execute the Statement for city
if (!($result3 = mysql_query($searchStmt3, $link))) {
   DisplayErrMsg(sprintf("Error in executing %s stmt", $searchStmt3));
   DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link),
mysql_error($link)));
   exit();
}


$num = mysql_numrows($result);
include("header.php");
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<body TEXT="#0000ff" bgcolor=white>

<h1 ALIGN="CENTER"><font SIZE="5" FACE="Arial">OFFERTE VOLI ENTRATA
DATI</font></h1>

<form ACTION="flight.php" METHOD="POST">
  <table WIDTH="100%" BORDER="1" CELLPADDING="2" CELLSPACING="3">
<COL WIDTH="59*">

==== removed some lines to shorten the mail ================

    <tr>
      <td WIDTH="22%"><font SIZE="2" FACE="Arial">DESTINAZIONE</font></td>
      <td WIDTH="55%"><input type=radio name=ndest
value="n" checked><select NAME="destinazione">
<?php
$i=0;
while($row1 = mysql_fetch_object($result1)) {

// Display records for destinazione/Country
echo("<option value=$row1->contid> $row1->country");

}
?>
</select>
<select name="city">
<?php
while($row3 = mysql_fetch_object($result3)) {

// Display records for city
echo("<option value=$row3->id>$row3->city");

}
?>


=================== Tables Structures ======================
city

| id        | int(5)      |      | PRI |         | auto_increment |
| city      | varchar(35) |      | MUL |         |                |
| countryid | int(5)      

country

| id      | int(5)      |      | PRI |         | auto_increment |
| country | varchar(35) |      | MUL |         |                |
| contid  | int(5)   

flight
| id                | int(11)      |      | PRI |         | auto_increment
| compagnia_aerea   | varchar(255) | YES  |     |         |
| contid            | int(5)       |      |     | 0       |
| cityid            | int(5)       |      |     | 0       |
| airport           | varchar(40)  |      |     |         |
| partenza          | date         | YES  |     |         |
| valido_fino       | date         | YES  |     |         |
| prezzo_pubblicato | varchar(255) | YES  |     |         |
| curr2             | char(3)      | YES  |     |         |
| prezzo_offerta    | varchar(255)

The contid field in the country table holds unique ids for each
country.  The city.id holds unique ids for each city and is linked to the
country table with the countryid.

The flight.contid and flight.cityid holds values of the the country and
city tables.

TIA

Adrian


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to