Connecting Tech Pros Worldwide Forums | Help | Site Map

Issue passing a value

Chrisjc's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Posts: 357
#1: Jan 15 '08
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // =========================================================
  3. //  Populate the state selection list from the database
  4. // =========================================================
  5. echo '<form action="dealerlocater.php" method="post">';
  6. echo '<select id="state" name="state" style="margin-bottom:4px;font-family: Tahoma; font-size: 10pt; height:28px;width:184px;">';
  7. echo '<option value="">Select Your State</option>';
  8. // =========================================================
  9. // Connection to the Database
  10. // =========================================================
  11. include ('db functions/db_connect.php');
  12. // =========================================================
  13. // SELECT state to make drop down list
  14. // =========================================================
  15. $res = mysql_query("SELECT state FROM dealerlocater GROUP BY state ORDER BY state")
  16.    or die("Invalid query: " . mysql_query());
  17. while ($row = mysql_fetch_assoc($res)) {
  18.    $st = $row['state'];
  19.    echo "<option value='$st'>$st</option>";
  20. }
  21. echo '</select>';
  22. echo '<br>';
  23. echo '<input type="submit" name="Submit" value="Submit">';
  24. ?>
  25. </form>
  26.  

and here is the code to "dealerlocater.php"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // =========================================================
  3. // Connection to the Database
  4. // =========================================================
  5. include ('db functions/db_connect.php');
  6. mysql_select_db($dealerlocater);
  7.  
  8. $query= "select * from dealerlocater where * '" . $_POST['*'] . "'"; 
  9. echo $query; 
  10.  
  11. $result= mysql_query($query); 
  12. $num_results = mysql_num_rows($result); 
  13.  
  14. for ($i=0; $i <$num_results; $i++) 
  15. $row = mysql_fetch_array($result); 
  16. echo "state: ", $row['state'], ": ",$row['state']; 
  17. ?>
  18.  
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's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Posts: 357
#2: Jan 15 '08

re: Issue passing a value


Can be closed.


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