Issue passing a value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chrisjc
    Contributor
    • Nov 2006
    • 375

    Issue passing a value

    First off here is the link to my page

    Link to page

    I am having an issue passing the "State" value to "dealerlocater. php" page that I have created, I have my index.php which will pull from my database and list all the States in a drop down.

    I now am trying to pass a selected state to “dealerlocater. php” which in return would post up all entries found in the database.

    How ever I am having an issue with my code could some one please take a look-see and let me know what I am missing here? Iv been stuck on this for a few days now. =(

    Here is my code to index.php
    Code:
    <?php
    // =========================================================
    //  Populate the state selection list from the database
    // =========================================================
    echo '<form action="dealerlocater.php" method="post">';
    echo '<select id="state" name="state" style="margin-bottom:4px;font-family: Tahoma; font-size: 10pt; height:28px;width:184px;">';
    echo '<option value="">Select Your State</option>';
    // =========================================================
    // Connection to the Database
    // =========================================================
    include ('db functions/db_connect.php');
    // =========================================================
    // SELECT state to make drop down list
    // =========================================================
    $res = mysql_query("SELECT state FROM dealerlocater GROUP BY state ORDER BY state")
       or die("Invalid query: " . mysql_query());
    while ($row = mysql_fetch_assoc($res)) {
       $st = $row['state'];
       echo "<option value='$st'>$st</option>";
    }
    echo '</select>';
    echo '<br>';
    echo '<input type="submit" name="Submit" value="Submit">';
    ?>
    </form>

    and here is the code to "dealerlocater. php"
    Code:
    <?php
    // =========================================================
    // Connection to the Database
    // =========================================================
    include ('db functions/db_connect.php');
    mysql_select_db($dealerlocater);
    
    $query= "select * from dealerlocater where * '" . $_POST['*'] . "'"; 
    echo $query; 
    
    $result= mysql_query($query); 
    $num_results = mysql_num_rows($result); 
    
    for ($i=0; $i <$num_results; $i++) 
    { 
    $row = mysql_fetch_array($result); 
    echo "state: ", $row['state'], ": ",$row['state']; 
    } 
    ?>
    Once I can get the value passed and it knows what to only look for calling on the columns I wish to display will be rather easy.
  • Chrisjc
    Contributor
    • Nov 2006
    • 375

    #2
    Can be closed.


    Fixed topic... other issues however we seem to be short experts. Found help via another MB.

    Comment

    Working...