Jump to content


Photo

dont get if loop lol


  • Please log in to reply
5 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 March 2006 - 07:19 PM

Advance thank you, i am currently doing a home virtul couse and dont understand the if statement.

example this is the if concept i thnk correct.
if(condition)
{
}

But i have got lost here please help to exsplain the if code below brocken down, i need to no this part in deatal
for($i = 0; $i < 6; $i++)

within the for condition i = 0 ; then i less then 6 but that dont make sence to me,lol to stop the loop you use i++ meaning add one please help you can see where i am getting stuck the i<6 driving me mad , lol

please exsplain in a real baby terms sorry but getting so confused thats with book cd and internet.

<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 10 March 2006 - 07:36 PM

Basically all waht the code does is the following:

<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>
Setup a variable called i and assign a value of 0.
Next we basically say if $i is less than 6 then increment $i by 1.
The first bit of the code ($i = 0) is only executed once as each time php goes through the loop it will only execute the secound and thrid parts of the for loop.
Now everytime php loops through the loop it'll echo the current value of $i and a line break so you'll get the following result:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]1
2
3
4
5
6[/quote]
Hope that helps

#3 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 10 March 2006 - 07:43 PM

[!--quoteo(post=353688:date=Mar 10 2006, 07:36 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Mar 10 2006, 07:36 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Basically all waht the code does is the following:

<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>
Setup a variable called i and assign a value of 0.
Next we basically say if $i is less than 6 then increment $i by 1.
The first bit of the code ($i = 0) is only executed once as each time php goes through the loop it will only execute the secound and thrid parts of the for loop.
Now everytime php loops through the loop it'll echo the current value of $i and a line break so you'll get the following result:
Hope that helps
[/quote]


to put this in english:

i starts at 0 ($i = 0) and while i is less than 6 ($i < 6) increment the value of i by 1 ($i++)
call me a safe bet, i'm betting i'm not

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 March 2006 - 07:43 PM

[!--quoteo(post=353688:date=Mar 10 2006, 07:36 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Mar 10 2006, 07:36 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Basically all waht the code does is the following:

<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>
Setup a variable called i and assign a value of 0.
Next we basically say if $i is less than 6 then increment $i by 1.
The first bit of the code ($i = 0) is only executed once as each time php goes through the loop it will only execute the secound and thrid parts of the for loop.
Now everytime php loops through the loop it'll echo the current value of $i and a line break so you'll get the following result:
Hope that helps
[/quote]

thank you so much how do i use it with a string meaning charecters so that man shows 6 times not a number.

thank you
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 10 March 2006 - 07:44 PM

[!--quoteo(post=353690:date=Mar 10 2006, 07:43 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 07:43 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
to put this in english:

i starts at 0 ($i = 0) and while i is less than 6 ($i < 6) increment the value of i by 1 ($i++)

or you could say "increment the value of i by 1 until the value of i is 5, then stop"
[/quote]

call me a safe bet, i'm betting i'm not

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 March 2006 - 07:49 PM

to put this in english:

i starts at 0 ($i = 0) and while i is less than 6 ($i < 6) increment the value of i by 1 ($i++)

or you could say "increment the value of i by 1 until the value of i is 5, then stop"


Thank you for the exsplnation in english perfect cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users