While Loops in PHP- 2. while loop syntax


#1


https://www.codecademy.com/courses/web-beginner-en-5YvPF/0/2?curriculum_id=5124ef4c78d510dd89003eb8


How does this code not work. please help me because i need help on the php thing.thank you.

<!DOCTYPE html>
<html>
    <head>
		<title>Your First PHP while loop!</title>
	</head>
	<body>
    <?php
	$loopCond = true;
	while ($loopCond == true){
		//Echo your message that the loop is running below
		echo "<p>And now it's done.</p>";
		$loopCond = false;
	};
	
    ?>
    </body>
</html>


#2

Please make sure to format your code correctly next time you post... However, I did find your issue.

There should be no semicolon after the closing curly brace that closes the while loop. That will throw an error.


#3

At first you have to write The loop is running instead of And now it's done.
so here after

while ($loopCond == true){

write The loop is running inside p tag
and after closing while loop
you have to print
And now it's done

and for more information you can write

while ($loopCond )
same meaning
while ($loopCond == true)


#4

i do not understand what you mean my friend.


#5

what didn't you understand???


#6

when you said "after closing the loop you have to print"


#7

Actually it doesn't matter.you can write it(And now it's done) inside the while loop too.


#8

i tried it but dont work


#9

give me your full code


#10

<!DOCTYPE html>
<html>
    <head>
		<title>Your First PHP while loop!</title>
	</head>
	<body>
    <?php
	$loopCond = true;
	while ($loopCond == true){
		//Echo your message that the loop is running below
		echo "<p>And now it's done.</p>";
		$loopCond = false;
	}
	
    ?>
    </body>
</html>

#11

you are told to do

Inside the curly braces, use echo to output "<p>The loop is running.</p>"

see

while ($loopCond == true){
         //Echo your message that the loop is running below
           echo "<p>The loop is running.</p>";
           $loopCond = false;
}

#12

when i click save and submit the thing keeps on spinning there is some thing wrong


#13

refresh/reload your browser


#14

done that lots of times


#15

have you understand everything?


#16

forget it thanks for helping me though


#17

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.