Click to See Complete Forum and Search --> : Using $_POST


scottyrob
04-09-2006, 12:44 PM
Hi folks.. I have these two pages

drop_down.php

<?
require 'db_connect.php';

$query = ("SELECT Attend FROM Permission_To_Camp");
$result = mysql_query($query);

if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
?>

<form name='Form1' action='dropdown_results.php' method='post'>
<select name='Attend_Dropdown'>
<? while ($row = mysql_fetch_assoc($result)) { ?>
<option value="<? '.$row['Attend'].' ?>"><? '.$row['Attend'].' ?></option>
<? } ?>
<input type='submit' value='Submit'>\n";
</select>
</form>

<?
mysql_free_result($result);
?>


dropdown_results.php

<?
require 'db_connect.php';

$query = "SELECT * FROM Permission_To_Camp WHERE location = '".$_POST['Attend_Dropdown']."'";
$result = mysql_query($query);

if (!$result) {
$message = 'Invalid query:' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}

while ($row = mysql_fetch_assoc($result)) {
echo $row['Attend'];
echo $row['Location'];
echo $row['Fromto'];
echo $row['Leadership'];

}

mysql_free_result($result);
?>


drop_down.php works fine, i can select and item from the menu, but when i submit the data to the next page, i cannot see anything on it, just a white page... Any ideas why?

NogDog
04-09-2006, 01:00 PM
You're populating your dropdown with values from the Attend column, but your where condition on the next page is using that value against the Location column; leading me to believe you're returning 0 rows with that query. However, without knowing the logic and content of your database, it's hard to say.

scottyrob
04-09-2006, 01:05 PM
NogDog, please give me the award for the stupidity.. Thanks for that, works now!

scottyrob
04-09-2006, 01:34 PM
Little help again please.. lol.. if you go to http://www.loddonexplorers.co.uk/newdesign/test_folder/camp.php and click submit you go to the next page which is just text... it is missing a chunk at the top of it! can you figure out why?

code is at http://www.loddonexplorers.co.uk/newdesign/test_folder/pcform.txt