|
Posted by Jim Michaels on 02/12/06 05:50
"Leszek" <leszekt80@poczta.onet.pl> wrote in message
news:drnpvd$tis$1@news.onet.pl...
> Hi.
>
> I have a problem with a form.
> There are some select dropdown lists
> for($i=0;$i<=$nrooms;$i++)
usually if $nrooms is defined like I think it is, you should be using <
instead of <= because you are starting with 0 as an array index, not 1.
for instance, if you have 5 rooms, and you want to count from 0 to 4,
for($i=0;$i<5;$i++)
or if you want to count from 1 to 5,
for($i=1;$i<=5;$i++)
this is common C/C++/PHP/Javascript/Java practice. Otherwise, $i is
accessing the array out of bounds.
> {
> echo "<option value=\"$i\"";
>
> if($_POST[$dane[$idhotelu]['zamow'][$k]]==$i){ // $k is
> incremented in other loop
> echo" selected";
> }// endif
> echo">$i</option>\n";
> }//endfor
> echo"</b></select></td>";
>
> Trouble is that after reloading this form if condition is true for $i==0
> even if $dane[$idhotelu]['zamow'][$k] is not zero
>
> I think i'm making a mistake while accessing $_POST array but i' don't
> know where
>
> Thanks for help...
> Leszek
>
>
Navigation:
[Reply to this message]
|