Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamically created checkbox

Guest
Feb 22, 2011 Feb 22, 2011

I have a script that was working, however I discovered it was only working

in IE7, not in FF or Chrome. It also has stopped working in IE7 once I put

it on the remote server.  It is to create checkboxes from data called from

the db. I have echo'd the mysql_num_row and am getting a result, so the

query seems to be working.  At this point I get a blank page.  Can someone

point me in the right direction to get this working  (again).

$choice=$_POST['state'];


mysql_select_db($database_assess,  $assess_remote);
$query_Recordset1 = ("SELECT * FROM `counties` WHERE  state_id =
'$choice'")or die(mysql_error());
$Recordset1 =  mysql_query($query_Recordset1, $assess_remote) or 
die(mysql_error());
$row_Recordset1 =  mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 =  mysql_num_rows($Recordset1);
   <?php
echo  "$totalRows_Recordset1";
echo "$row_Recordset1";
if (  isset($_POST['submit']) ) { // if form is submitted, process  it

//////////////I believe my issue is  below\\\\\\\\\\\\\\\\\\\\\\\\

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
$county_choice=$_SESSION['county{$1}'];
print "<form  action=\"phpForm3.php\" method=\"POST\">\n";

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

print  "<th>  </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($Recordset1) ) {
$i++;
print  "<tr>\n";

print "<td><input type=\"checkbox\"  name=\"county$i\"
value=\"$row[name]\"></td>\n";

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";
}

?>

Would appriciate your  help.

Thank you.
--
Gary
TOPICS
Server side applications
458
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 23, 2011 Feb 23, 2011

$choice=$_POST['state'];


mysql_select_db($database_assess,  $assess_remote);
$query_Recordset1 = ("SELECT * FROM `counties` WHERE  state_id =
'$choice'")or die(mysql_error());
$Recordset1 =  mysql_query($query_Recordset1, $assess_remote) or 
die(mysql_error());
$row_Recordset1 =  mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 =  mysql_num_rows($Recordset1);
   <?php
echo  "$totalRows_Recordset1";
echo "$row_Recordset1";
...

?>

Would appriciate your  help.

Thank you.
--
Gary

Most likely it´s the extra <?php start of a scripting block I marked bold @ line 9 which triggers a PHP parse error.

At this point I get a blank page.

...what indicates that there´s something wrong with your PHP code. Whenever this happens, please turn on PHP error reporting by adding the line

error_reporting(E_ALL ^ E_NOTICE);

@ line 1

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 23, 2011 Feb 23, 2011

Gunter

Thank you for your reply.  I don't really know if that was the issue, I ended up re-writing it.  It was curious though that it had a problem in one browser to another given they were both running through the same server.

GAry

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 23, 2011 Feb 23, 2011
LATEST

Hi Gary,

I don't really know if that was the issue

Trust me, adding a <?php start tag inside a code block is an issue 😉

Glad you got it solved !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines