Reply to Re: WHILE loop problems

Your name:

Reply:


Posted by Tom on 04/09/07 18:06

On Sun, 8 Apr 2007 14:49:17 -0700, Shooter wrote...
>
>I'm having trouble setting up a while loop, and I think I'm creating
>overlapping brackets. I'm trying to set up a script to check for up to 3
>images to display on a profile page, then put a notice at the bottom. My
>initial efforts either get a blank page or the notice appearing a few
>hundred times. Below is my original (working) script to display a single
>image. After that is my attempts at adding a while loop. Is there a better
>way of doing this??
>
>Thanks,
>Wm


With a "for" loop you can control the specific number of tries...

$i = 0;
for($i = 0; $i <= 3; $i++)
{

}

Tom
--
Newsguy.com
90+ Days Retention
Higher levels of article completion
Broader newsgroups coverage



>
>
>Original/working version:
>
>//start imagename function
> $imagename = "$lastname$firstname";
> $imagename = str_replace(" ", "","$imagename");
> //end imagename function
> //$filename = '../images/$imagename.jpg';
> $image_info =
>@getimagesize("http://www.mydomain.org/images/$imagename.jpg");
> $type=$image_info[2];
> if ($type == 0) {
> // file_exists(realpath($filename)); {
> print "&nbsp;";
> } else {
> print "<IMG SRC=\"../images/$imagename.jpg\"><BR>";
> print "<FONT color=\"#000000\" face=\"Arial, Helvetica, sans-serif\"
>size=\"1\">
> &copy; $firstname $lastname. All Rights Reserved.</FONT>";
> }
>
>
>
>
>Trying to add a loop:
>
>//start imagename function
> //begin new code
> $imagenum=1;
> while ($imagenum<4) {
> //end new code
> $imagename = "$lastname$firstname$imagenum";
> $imagename = str_replace(" ", "","$imagename");
> //end imagename function
> //$filename = '../images/$imagename.jpg';
> $image_info =
>@getimagesize("http://www.mydomain.org/images/$imagename.jpg");
> $type=$image_info[2];
> if ($type == 0) {
> // file_exists(realpath($filename)); {
> print "&nbsp;";
> } else {
> print "<IMG SRC=\"../images/$imagename.jpg\"><BR>";
> $imagenum = $imagenum++;
> } // end while loop
> print "<FONT color=\"#000000\" face=\"Arial, Helvetica, sans-serif\"
>size=\"1\">
> &copy; $firstname $lastname. All Rights Reserved.</FONT>";
> }
>
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация