www.webdeveloper.com
Results 1 to 4 of 4

Thread: Data base info won't display on webpage

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Location
    Israel
    Posts
    2

    Data base info won't display on webpage

    Hello There!
    I've created a data base with 4 columns "city, zipcode, dfw, love) 2 of these columns should be visible on my web page: http://www.riva-limo.com/rates.php
    After the surfer is choosing the airport from the drop-down list he should see "Select a city..." in the next field and then he will be able to choose from a drop-down list of cities.
    My problem is that it seems that the information from the data base is loaded to that field but it is not visible, and if you blindly select from the cities list you can see the same problem happening again in the zip code field.
    My code looks like this:

    if ($_GET['act']=='getCity') {
    $query_city = "SELECT DISTINCT city FROM rates ORDER BY city ASC";
    $city = mysql_query($query_city, $db) or die(mysql_error() ." " .$query_city);
    $row_city = mysql_fetch_assoc($city);
    //$totalRows_groups = mysql_num_rows($groups);
    $options[] = "{optionValue: '', optionDisplay: 'Select a City...'}";
    do {
    $options[] = "{optionValue:'".$row_city['city']."', optionDisplay: '".htmlentities(trim($row_city['city'])) ."'}";
    } while ($row_city = mysql_fetch_assoc($city));

    // print_r($options);
    $theOptions = implode(",", $options);
    $theOptions = "[".$theOptions."]";

    echo $theOptions;

    }


    if ($_GET['act']=='getZip') {
    $query_zip = sprintf("SELECT zipcode FROM rates WHERE city = '%s' ORDER BY zipcode ASC",$_GET['city']);
    $zip = mysql_query($query_zip, $db) or die(mysql_error() ." " .$query_zip);
    $row_zip = mysql_fetch_assoc($zip);
    //$totalRows_groups = mysql_num_rows($groups);
    $options[] = "{optionValue: '', optionDisplay: 'Select a Zipcode...'}";
    do {
    $options[] = "{optionValue:'".$row_zip['zipcode']."', optionDisplay: '".htmlentities(trim($row_zip['zipcode'])) ."'}";
    } while ($row_zip = mysql_fetch_assoc($zip));

    // print_r($options);
    $theOptions = implode(",", $options);
    $theOptions = "[".$theOptions."]";

    echo $theOptions;

    Thank you for your help!
    Chilik

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,357
    Here's the above code in [php] tags, hopefully making it easier for myself and others to read it and then maybe help you:
    PHP Code:
    if ($_GET['act']=='getCity') { 
        
    $query_city "SELECT DISTINCT city FROM rates ORDER BY city ASC";
        
    $city mysql_query($query_city$db) or die(mysql_error() ." " .$query_city);
        
    $row_city mysql_fetch_assoc($city);
        
    //$totalRows_groups = mysql_num_rows($groups);
        
    $options[] = "{optionValue: '', optionDisplay: 'Select a City...'}";    
        do {
            
    $options[] = "{optionValue:'".$row_city['city']."', optionDisplay: '".htmlentities(trim($row_city['city'])) ."'}";
        } while (
    $row_city mysql_fetch_assoc($city));
        
    //    print_r($options);
        
    $theOptions implode(","$options);
        
    $theOptions "[".$theOptions."]";

        echo 
    $theOptions;

    }


    if (
    $_GET['act']=='getZip') { 
        
    $query_zip sprintf("SELECT zipcode FROM rates WHERE city = '%s' ORDER BY zipcode ASC",$_GET['city']);
        
    $zip mysql_query($query_zip$db) or die(mysql_error() ." " .$query_zip);
        
    $row_zip mysql_fetch_assoc($zip);
        
    //$totalRows_groups = mysql_num_rows($groups);
        
    $options[] = "{optionValue: '', optionDisplay: 'Select a Zipcode...'}";    
        do {
            
    $options[] = "{optionValue:'".$row_zip['zipcode']."', optionDisplay: '".htmlentities(trim($row_zip['zipcode'])) ."'}";
        } while (
    $row_zip mysql_fetch_assoc($zip));
        
    //    print_r($options);
        
    $theOptions implode(","$options);
        
    $theOptions "[".$theOptions."]";

        echo 
    $theOptions
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,357
    You need to close the <option> tag with its closing ">" before the optionDisplay call.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Feb 2010
    Location
    Israel
    Posts
    2

    Problem Resolved(for the time being)

    Thanks Guys,
    I've tried to re saved the PHP files and replaced them on the server and it started functioning again, I've posted "for the time being" because I had this phenomenon earlier and it stopped functioning after a while... I'm hoping that it will last now.

    Thank you for willing to help me!
    Have a nice day!
    Chilik

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles