php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5550 <input type=checkbox name=\"test[$i]\"> is not working correctly when submittin
Submitted: 2000-07-13 06:31 UTC Modified: 2000-07-26 21:50 UTC
From: stormlord at the dot net dot nz Assigned:
Status: Closed Package: Other
PHP Version: 4.0 Release Candidate 2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stormlord at the dot net dot nz
New email:
PHP Version: OS:

 

 [2000-07-13 06:31 UTC] stormlord at the dot net dot nz
<?
if(!$submit)
{
  echo"<form method='POST'>\n";
  for($i=0;$i<10;$i++)
  {
    echo"<input type=checkbox name=\"todel[$i]\" value=\"pjd$i\"><br>\n";
  }
  echo"<input type=submit name=submit value=submit><br>\n";
  echo"</form>\n";
}
else
{
  for($i=0;$i<count($todel);$i++)
    echo"$i - todel = ".$todel[$i]."<br>";
}
?>


Ok.. now try selecting 2,3,4 in the check box and submit and see if it gives you
the correct values.. its just not working correctly!!! :LLLLL Help!! :)

I've installed PHP4 the way the www.linuxguruz.org site have listed in their
tutorial for PHP + MYSQL + SSL :)

Cheers
Paul.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-26 21:50 UTC] zak@php.net
This is a logical error in the program, not a bug.

When you loop over your values with the line:
  for($i=0;$i<count($todel);$i++)
you are only running the loop as many times as you have elements in your array. If 2,3,4 are selected, then the count of $todel is 3... so the 4th element will never be reached.

Try changing the contents of your else statement to:
foreach ($todel as $key => $value)
    echo "$key - todel = ".$todel[$key].'<br>';
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 21:01:28 2024 UTC