Re: Dynamically Created Checkboxes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Pete Ford" <pete@xxxxxxxxxxxxx> wrote in message 
news:62.C1.32612.D49D46D4@xxxxxxxxxxxxxxx
> This bit?
>
> On 22/02/11 22:06, Gary wrote:
>> for($i=1; $i<=$_POST['counties']; $i++) {
>> if ( isset($_POST["county{$i}"] ) ) {
>
> You loop over $_POST['counties'] and look for $_POST["county$i"]
>
> I suspect that there is no field 'counties' in your form, so the server is 
> complaining about the missing index - seems likely that the production 
> server
> is not showing the error, but instead just giving up on the page.
>
> I think the IE7/Firefox browser difference is a red herring: it wasn't 
> actually working in any browser, or the code changed between tests. 
> Remember, PHP is server side and generates HTML (or whatever). Unless you 
> tell the PHP what browser you are using and write PHP code to take account 
> of that (not generally recommended) then the server output is the same 
> regardless of browser.
>
> -- 
> Peter Ford, Developer                 phone: 01580 893333 fax: 01580 
> 893399
> Justcroft International Ltd. 
> www.justcroft.com
> Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United 
> Kingdom
> Registered in England and Wales: 2297906
> Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 
> 1XS


Pete

Once again, thank you for your help.

I was able to get it to work, I did not understand the browser differences 
either, but on my testing server on IE, it worked as I wanted but not on 
anything else.  I chopped out most of the code and ended up with this:

if ( isset($_POST['submit']) ) {} else {
print "<form action=\"phpForm3.php\" method=\"POST\">\n";
if ($Recordset1) {
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($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";
}
?>

Again, thank you.

Gary 



__________ Information from ESET Smart Security, version of virus signature database 5899 (20110223) __________

The message was checked by ESET Smart Security.

http://www.eset.com





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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux