PHP-and-MySQL/C2/Loops-For-Statement/English-timed

From Script | Spoken-Tutorial
Revision as of 15:58, 2 January 2013 by Minal (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
0:00-0:14 The basic principle of for loops is that it will repeat a block of codes the number of times you specify, using not only a condition but also the initialization in the beginning and the increment at the end.
0:18-0:25 So how much you want to increment your variable determines the number of times your variable loops by.
0.30-0.38 So, it is a bit more complex to write. However it looks good , it does the job and its very compact.
0.42-0.43 Now we write 'for'
0.44-0.53 so you have got three parts of your code here,and your block and that is all you need and your content can go here.
0.54-1.03 So, I am going to say 'echo' here and let's create a variable 'num'. So, we have echoed out 'num'.
1.03-1.13 In here, we write num =1, not = = 1 because we are setting the variable num to the value of 1.
1.14-1.22 Then we have a condition. For eg, while num < = to 10
1.22-1:31 Then, we have the increment values. So, we are going to have num ++ and the loop is done.
1:32-1:37 So, we type 'For', and our variable num=1
1:38-1:47 Then we have our condition 'While num< =10, the loop will continue, and then we have num ++
1:47-1:52 As you can see this is much more useful than having num ++ down below .
1:53-1:55 and we need not declare this up here.
1:56-1:59 It can be declared inside these parentheses.
2:00-2:02 O.K., I forgot the line-break.
2:03-2:07 I’ll add a line break on to the end of this.
2:09-2:10 Refresh.
2:11-2:12 There you go.
2:15-2:17 You've got your loop ten times.
2:18-2:25 And as it has been specified in such a way it will loop only when num is less than or equal to 10.
2:26-2:28 After that the loop will break and you may continue with the rest of the script.
2:31-2:36 This is a bit more complex but once you learn the basics you will find it a lot easier .
2:37 Thanks for watching.

Contributors and Content Editors

Minal, PoojaMoolya, Pratik kamble, Sandhya.np14