mardi 26 avril 2016

if statements in while loop?

Hi I am just wondering how do if statements work in while (loop)? I want the page to display number through 1 to 10 and show special comment for number 1 and 2. Thanks so much!

<?php
$x=1;
while($x <= 10) {
echo "". $x . "<br />";
$x = $x + 1; }

if ($x = 1 ) {
echo "".$comment."";
    $comment = "this is one!";}     
elseif ($x = 2) {
echo "".$comment."";
    $comment = "this is two!";}

?>

Aucun commentaire:

Enregistrer un commentaire