Welcome! Log In Create A New Profile

Advanced

PHP Five - Programming Loops

Posted by Gaia77490614 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
PHP Five - Programming Loops
February 15, 2012 04:04PM
I have completed this section
Re: PHP Five - Programming Loops
February 16, 2012 08:36AM
So far so good on my side as well
avatar Re: PHP Five - Programming Loops
February 16, 2012 12:07PM
progress is all that matters. section completed!
Re: PHP Five - Programming Loops
February 19, 2012 12:09PM
I have completed this section. No problems with it smile Understood it fine.
Re: PHP Five - Programming Loops
February 20, 2012 08:33AM
Completed this section, taking it slowly but surely.
I don't want to rush through everything and by August don't remember any of it
Re: PHP Five - Programming Loops
February 20, 2012 02:22PM
Guys please show us some creativity, dont tell us you have completed a section but what you have learned out of that section by way of example.

Like i want to print out these stars.
*
**
***
****
*****
for ($i = 0; $i<5; $i++)
{
for ($x=0; $x<=$i; $x++)
{
echo '*';
}
echo '<br />';
}

Programming guys is awesome.
Re: PHP Five - Programming Loops
February 20, 2012 07:58PM
Completed this section.

Since there was no example for the do while, I will share a scenario where I have used it before. The do while loop can be very handy when reading text from a file. If you read the file one line at a time, you won't know when you have reached the end of the file unless you validate the input after reading the first line. Therefore you will execute the loop at least once to check if the input and then continue if it is not the end of the file. (The same functionality is sometimes used when communicating with socket servers)
avatar Re: PHP Five - Programming Loops
February 20, 2012 08:18PM
I don't think you have to stress yourself flaunting your codes all around the forum Innocent. The forum is meant for posting questions, helpful links, sharing issues and resolving them. Cheers!
Re: PHP Five - Programming Loops
February 21, 2012 08:02AM
I totally agree with 77553055 . This forums is there for assisting each other with helpfull links and unsolvable questions smile
Re: PHP Five - Programming Loops
February 21, 2012 10:37AM
Hi guys

All i can say guys is that seing the sun is a luxury to me
cheers
Re: PHP Five - Programming Loops
February 21, 2012 11:06AM
HI 77586182

Can you share some code with working on socket server or webservice i have never worked on these technologies
Thanks
avatar
Mac
Re: PHP Five - Programming Loops
February 21, 2012 11:29AM
77592972_innocent Wrote:
-------------------------------------------------------
> HI 77586182
>
> Can you share some code with working on socket
> server or webservice i have never worked on these
> technologies
> Thanks

Learn to walk before you run.... these are advanced technologies! Rather keep to what we are studing at this point.
Re: PHP Five - Programming Loops
February 21, 2012 12:48PM
Working with loops is awesome guys.Now i can,t wait to work with arrays.It has been easy,so guys what is the most difficult part in php?
Re: PHP Five - Programming Loops
February 21, 2012 01:44PM
H.Malatji
Arrays can be complicated, im currently working on three dimensional arrays, like this

Language: PHP
array = array( array(';name';=>';innocent';, ';surname';=>';langa';, ';geography'; => array(';province';=>';kzn';, ';city';=>';durban';)) array(';name';=>';simo';, ';surname';=>';zaca';, ';geography'; => array(';province';=>';gauteng';, ';city';=>';sandton';));
Walking this array can really take sometime.
Re: PHP Five - Programming Loops
February 22, 2012 10:15AM
I've also completed this section and an learning from you guys, thanx very much.
avatar Re: PHP Five - Programming Loops
February 25, 2012 05:11PM
I've completed this section.

A mistake I have made before is to set the counter inside the loop, which results in the loop cycling 'forever' smiling smiley
I have to remind myself now to:
(1) always create the counter variable outside of the loop!
(2) to make 100% certain that the loop will always complete – by not resetting the variable unwittingly each time around the loop and by making sure that the condition for keeping the loop running will without a doubt at some point be false and kick out of the loop.
Re: PHP Five - Programming Loops
February 25, 2012 06:20PM
Hi, referring to H, Malatji. For me at the moment is remembering the codes, as I am learning new things in the sea rescue as well, I've gotten myself confused with some of the coding in the for loop. but I will definitely rise to ask should I get stuck.
Regardssmile
Re: PHP Five - Programming Loops
March 02, 2012 03:49PM
I have completed this section!
Re: PHP Five - Programming Loops
March 02, 2012 03:53PM
I found a webpage with some more, unusual php looping examples. Check it out at Using-php-strings-unusual-ways
Re: PHP Five - Programming Loops
March 02, 2012 09:15PM
I have completed this section!
Re: PHP Five - Programming Loops
March 03, 2012 12:06PM
owned this section
Re: PHP Five - Programming Loops
March 08, 2012 09:47AM
For a times table that goes backwards & forwards, and to keep the values entered in the text fields - here's some code:
Language: PHP
<head> <title>A Times Table Programme</title>   <?PHP $times = 2; $keepstart = 1; $keepend = 10;   if (isset($_POST[';Submit1';])) { $keepstart = $start = $_POST[';txtStart';]; $keepend = $end = $_POST[';txtEnd';]; $times = $_POST[';txtTimes';];   if($start <= $end){ for($start; $start <= $end; $start++) { $answer = $start * $times; print $start . " multiplied by " . $times . " = " . $answer . "<br />"; } } else { for($start; $start >= $end; $start--) { $answer = $start * $times; print $start . " multiplied by " . $times . " = " . $answer . "<br />"; } } print "<p></p>"; } ?>   </head>   <body>   <FORM NAME = frmOne Method = "POST" Action = "timesTable.php"> Start Number: <INPUT TYPE = Text NAME = txtStart SIZE = 5 value = <?PHP print $keepstart; ?> > End Number: <INPUT TYPE = Text NAME = txtEnd SIZE = 5 value = <?PHP print $keepend; ?> > Multiply By: <INPUT TYPE = Text NAME = txtTimes SIZE = 5 value = <?PHP print $times; ?> > <p></p> <INPUT TYPE = Submit Name = Submit1 VALUE = "Do Times Table"> <p></p> </FORM> </body>
Re: PHP Five - Programming Loops
March 08, 2012 10:09AM
Finished this section.
Re: PHP Five - Programming Loops
March 09, 2012 07:29PM
Completed the section.
Re: PHP Five - Programming Loops
March 10, 2012 01:20PM
Was tough to get my head around the concept of loops :/
I have finished this section.
Re: PHP Five - Programming Loops
March 11, 2012 05:16PM
Language: PHP
<?php echo ';Finished this chapter';; ?>
Re: PHP Five - Programming Loops
March 14, 2012 04:15PM
Interesting. Completed. Will surely come in handy soon !
Re: PHP Five - Programming Loops
April 15, 2012 09:14PM
Done.
Re: PHP Five - Programming Loops
May 03, 2012 10:33PM
I've completed this section, was confusing first time round, but finally understanding it betterthumbs up smiley
Sorry, you do not have permission to post/reply in this forum.