Cant Get Data

Cant Get Data

am 21.02.2011 18:09:25 von gary

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.

$county1=$_SESSION['county$i'];
$counties=$_SESSION['counties'];
$row_name=$_SESSION['name'] = $row[name];
$count_choice=$_SESSION['name'];
$result1=$_SESSION['$result'];
$choice=$_POST['state'];
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.
";
}
}

} else { // if form isn't submitted, output the form
$county_choice=$_SESSION['county$1'];
print "

\n";

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

if ($result) {
print "\n";

print "\n";
print "\n"; //2 fields in Counties table, State and County
print "\n";

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

print "\n";

echo "\n";

echo "\n";

echo "\n";

}//end while
print "
  State County
value=\"$row[name]\"> {$row['state_id']} {$row['name']}
\n";
} else {
echo("

Error performing query: " .
mysql_error() . "

");

}
print "\n";
print "\n";
}


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

$count_choice1=$_SESSION['county$i'];
$count_choice2=$POST['counties'];
$count_choice3=$_POST['name'];
$result1=$_SESSION['$result'];
/*$count_choice=$_SESSION['name']; */
$count_choice=$_POST['county$i'];
$choice=$_SESSION['name'];
$_POST["county$i"];


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


}
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.


Gary



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

The message was checked by ESET Smart Security.

http://www.eset.com





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

Re: Cant Get Data

am 22.02.2011 14:55:08 von Amit Tandon

--20cf3054ace37b9d0a049cdf5531
Content-Type: text/plain; charset=UTF-8

Dear Gary

$_SESSION variable would be available only if you have session_start() at
the top of the page. For $_POST, i presume u hve method POST defined for the
form element
============
regds
amit

"The difference between fiction and reality? Fiction has to make sense."


On Mon, Feb 21, 2011 at 10:39 PM, Gary wrote:

> 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.
>
> > $county1=$_SESSION['county$i'];
> $counties=$_SESSION['counties'];
> $row_name=$_SESSION['name'] = $row[name];
> $count_choice=$_SESSION['name'];
> $result1=$_SESSION['$result'];
> $choice=$_POST['state'];
> 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.
";
> }
> }
>
> } else { // if form isn't submitted, output the form
> $county_choice=$_SESSION['county$1'];
> print "\n";
>
> /*$link = mysql_connect("", "", "");
> mysql_select_db("");*/
> $result = mysql_query("SELECT * FROM `counties` WHERE state_id =
> '$choice'")
> or die(mysql_error());
>
> if ($result) {
> print "

\n";
>
> print "\n";
> print "\n"; //2 fields in Counties table, State and County
> print "\n";
>
> print "\n";
> //create table
> $i = 0;
> while ( $row = mysql_fetch_array($result) ) {
> $i++;
> print "\n";
>
> print "\n";
>
> echo "\n";
>
> echo "\n";
>
> echo "\n";
>
> }//end while
> print "
  State County
> value=\"$row[name]\">{$row['state_id']}{$row['name']}
\n";
> } else {
> echo("

Error performing query: " .
> mysql_error() . "

");
>
> }
> print "\n";
> print "\n";
> }
>
>
> This is the page that I am unable to get to call the checkbox selections
>
> > $count_choice1=$_SESSION['county$i'];
> $count_choice2=$POST['counties'];
> $count_choice3=$_POST['name'];
> $result1=$_SESSION['$result'];
> /*$count_choice=$_SESSION['name']; */
> $count_choice=$_POST['county$i'];
> $choice=$_SESSION['name'];
> $_POST["county$i"];
>
>
> $result = mysql_query("SELECT * FROM `counties` WHERE name = '$choice'") or
> die(mysql_error());
> /*$query = mysql_query("SELECT * FROM counties ");
> $result = mysql_query($query) or die ("Error in query: $query.
> ".mysql_error());;
> echo $row['name'];
> echo "$query";*/
> while($row = mysql_fetch_array($result))
> {
> echo $row['name'];
> /*"{$row['name']}
" ;*/
>
>
> }
> 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.
>
>
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus signature
> database 5893 (20110221) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--20cf3054ace37b9d0a049cdf5531--