View Single Post
  #1 (permalink)  
Old 05-10-2004, 02:29 PM
bufhal bufhal is offline
WebProWorld New Member
 
Join Date: May 2004
Location: Western New York
Posts: 17
bufhal RepRank 0
Default cannot get 12 fields back, only 3

Working on a web page with three dropdowns: Agency, Date and City. When a user clicks on one of the choices from the dropdown, a record(s) with all 12 fields are supposed to be returned in a pop up. I only have Agency City and Date being returned. The twelve fields I want returned are listed in the results.php file for output below. Both files are below--can someone please take a look and show me how to remedy this?
Thank you in advance..Bufhal

index.php
Code:
<?php 
// Connection to the db server and select active db 
$SQLlink = @mysql_connect("t.com", "wny", "947"); //creates a connection 

if (!$SQLlink) 
  Die("Couldn't connect to the db server."); // display error message on error 

if (!mysql_select_db("org", $SQLlink)) 
  Die("Couldn't access database.");          // display error message on error 

// perform query 
$data   = mysql_query("SELECT date, agency, city FROM agencies"); 

if (!$data) 
  Die(mysql_error());                        // display MySQL error message on error 

$agencies = Array(); 

while($row = mysql_fetch_array($data)) {     // assign results into arrays 
  $dates[]    = $row["date"]; 
  $agencies[] = $row["agency"]; 
  $cities[]   = $row["city"]; 
} 

$dates = Array_Unique($dates);               // remove duplicate values 
$agencies = Array_Unique($agencies); 
$cities = Array_Unique($cities); 

Sort($dates);                                // sort arrays 
Sort($agencies); 
Sort($cities); 

$date_out   = "<select name='date'   onchange=\"window.open('results.php?action=date&value='+this.value, 'agencyWin', 'location=yes,left=20,top=20');\">"; 
$agency_out = "<select name='agency' onchange=\"window.open('results.php?action=agency&value='+this.value, 'agencyWin', 'location=yes,left=20,top=20');\">"; 
$city_out   = "<select name='city'   onchange=\"window.open('results.php?action=city&value='+this.value, 'agencyWin', 'location=yes,left=20,top=20');\">"; 

$date_out   .= "<option>-- select date ---</option>"; 
$agency_out .= "<option>-- select agency ---</option>"; 
$city_out   .= "<option>-- select city ---</option>"; 

forEach ($dates as $value) 
  $date_out   .= "<option value='$value'>$value</option>"; 

forEach ($agencies as $value) 
  $agency_out .= "<option value='$value'>$value</option>"; 

forEach ($cities as $value) 
  $city_out   .= "<option value='$value'>$value</option>"; 


$date_out   .= "</select>\n"; 
$agency_out .= "</select>\n"; 
$city_out   .= "</select>\n"; 

echo $date_out.""; 
echo $agency_out.""; 
echo $city_out."
"; 

?>
and results.php
Code:
<?PHP 
$data   = mysql_query("select * FROM agencies"); 


if (!$data) 
  Die(mysql_error());                        // display MySQL error message on error 

$output = "<table border=1>\n";    // I can format table here 

if (mysql_num_rows($data) != 0) {            // in the case of results 
while($agency = mysql_fetch_array($data)) { 
    $output .= "<tr>"; 
    $output .= "<td>".$agency["date"]."</td>"; 
    $output .= "<td>".$agency["agency"]."</td>"; 
    $output .= "<td>".$agency["city"]."</td>";  
    $output .= "<td>".$agency["day"]."</td>"; 
    $output .= "<td>".$agency["time"]."</td>"; 
    $output .= "<td>".$agency["location"]."</td>"; 
    $output .= "<td>".$agency["building_room"]."</td>"; 
    $output .= "<td>".$agency["street"]."</td>"; 
    $output .= "<td>".$agency["zip"]."</td>"; 
    $output .= "<td>".$agency["phone"]."</td>"; 
    $output .= "<td>".$agency["contact"]."</td></tr>\n"; 
echo($output); 
    $output = ""; // clear buffer 
} 
}else{   // in case of NO results 
    echo("<tr><td colspan=11>No results</td></tr>"); 
} 
echo "</table>"; // end of table 

?> 
 // 
Close window
Reply With Quote