I have a 3 step form that calls the data from a mysql DB.  First is a 
dropdown to select a state, which then brings up a dynamically created check 
list of the counties in that state, so far all works well.  I am unable to 
get the checkbox choices to appear on the third page.

If someone could take a look at this and tell me where I am going wrong.

This is the code for the page that creates the checkboxes.  There are some 
extra lines in there where I was trying to get it to work. Again this works 
fine, but my guess is that see this may shed light.

$row_name=$_SESSION['name'] = $row[name];
if ( isset($_POST['submit']) ) { // if form is submitted, process it

for($i=1; $i<=$_POST['counties']; $i++) {
if ( isset($_POST["county$i"] ) ) {
print $_POST["county$i"]." is checked.<br/>";

} else { // if form isn't submitted, output the form
print "<form action=\"phpForm3.php\" method=\"POST\">\n";

/*$link = mysql_connect("", "", "");
$result = mysql_query("SELECT * FROM `counties` WHERE state_id = '$choice'") 
or die(mysql_error());

if ($result) {
print "<table width=200 border=1>\n";

print "<th>&nbsp; </th>\n";
print "<th> State </th>\n"; //2 fields in Counties table, State and County
print "<th> County </th>\n";

print "</tr>\n";
//create table
$i = 0;
while ( $row = mysql_fetch_array($result) ) {
print "<tr>\n";

print "<td><input type=\"checkbox\" name=\"county$i\" 

echo "<td>{$row['state_id']}</td>\n";

echo "<td>{$row['name']}</td>\n";

echo "</tr>\n";

}//end while
print "</table>\n";
} else {
echo("<P>Error performing query: " .
mysql_error() . "</P>");

print "<input type=\"hidden\" name=\"counties\" value=\"$i\"/>\n";
print "<input type=\"submit\" name=\"submit\" value=\"Go\"/>\n";

This is the page that I am unable to get to call the checkbox selections

/*$count_choice=$_SESSION['name'];  */

$result = mysql_query("SELECT * FROM `counties` WHERE name = '$choice'") or 
/*$query  = mysql_query("SELECT * FROM counties ");
$result = mysql_query($query) or die ("Error in query: $query. 
 echo $row['name'];
 echo "$query";*/
while($row = mysql_fetch_array($result))
    echo $row['name'];
         /*"{$row['name']}<br>" ;*/

echo "$choice";
/*echo $_SESSION['county$i'];
echo $_SESSION['counties'];
echo $_SESSION['name'];
echo "$count_choice";
echo "$row['name']";
echo "$county$1";
echo "$counties";
echo "$row_name"; */

Any Suggestions?

Thank you.


__________ Information from ESET Smart Security, version of virus signature 
database 5893 (20110221) __________

The message was checked by ESET Smart Security.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to