Log in

View Full Version : while and if loops


colicab-d
05-17-2003, 07:54 PM
Ok so i know that using and if inside an if is ok... but why shouldnt it work for having an if inside a while loop?

Anyway heres my dilema as the code below shows



while($r = mysql_fetch_array($galquery1)){

$galentid=$r['attachemntid'];

$galtime=$r['dateline'];

$galentry=$r['filedata'];

$galentryname=$r['filename'];

$galuserid=$r['userid'];

$galentryvisible=$r['visible'];

if($galentry){
$imgshow = "<img src = $bburl/attachment.php?postid=$galentid ><br>";
$imgshow.= "<a href = $bburl/attachment.php?postid=$galentid>Full Image</a><br><br>";
echo ("$imgshow");
}
else
{
//DONT SHOW EMPTY ATTACHMENTS
}



whys that not working eh? seems to work ok till i add an if inside a while.... :dead:

filburt1
05-17-2003, 07:59 PM
If you indent properly, you may see the problem. :)

colicab-d
05-17-2003, 08:04 PM
lol filburt , i have the } for the initial while down a few lines under an additional comment i dont wanna show of at mo lol

so i have it



while(this and that){

do this

if (something else){

do this

}

else
{
another something else
}


}