if (isset($_POST['submit'])) {
while($i<=5) {
$i=1;
$fld = 'pick'.$i;
$fld1 = 'addr'.$i;
$fld2 = 'dest'.$i;
$fld3 = 'tonn'.$i;
$fld4 = 'driv'.$i;
$fld5 = 'invn'.$i;
$fld6 = 'subc'.$i;
$fld7 = 'span'.$i;
if(isset($_POST[$fld])) {
mysql_query("INSERT INTO `jobs` (`ts`, `pick`, `addr`, `dest`, `tonn`, `driv`, `invc`, `subc`, `span`, `completed`) VALUES ('ts', '".$_POST["pick".$i]."', '".$_POST["addr".$i]."', '".$_POST["dest".$i]."', '".$_POST["tonn".$i]."', '".$_POST["driv".$i]."', '".$_POST["invn".$i]."', '".$_POST["subc".$i]."', '".$_POST["span".$i]."', 'no')", $connect);
echo ("<br>Inserted<br>");
}
$i++;
}
}
?>
Page 1 of 1
While loop issues in PHP...
#1
Posted 10 September 2009 - 08:23 PM
Any ideas why this is resulting in me having pages of "inserted"? I was under the impression that when $i=5 it shouldn't print any more...
If I am helping you and don't reply in 24 hours please send me a PM
There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
#2
Posted 20 September 2009 - 09:11 AM
This loop is a forever loop.
while (i <= 5){
i = 1; //look mom, no hands
i++;
}
#5
Posted 20 September 2009 - 06:35 PM
hahaha indeed i did... closed the if statement above the $i++ and hey look it works now
If I am helping you and don't reply in 24 hours please send me a PM
There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
Share this topic:
Page 1 of 1

Help


Back to top










