Re: WHILE loop problems



"Shooter" <SDshooter@xxxxxxxxxxx> wrote in message
news:46196360$0$5759$4c368faf@xxxxxxxxxxxxxxxxx
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??

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>";
}

Sorry to highjack the OP.
I find the above very curious personaly.
I could be wrong, but I thought "++" had a higher precedence than "=", in
fact I'm very sure it does.
However, having said that, "$imagenum++" is a post-increment, which would
suggest that although the "++" operator has higher precedence the
incrementation should occure after the assignment.
Although I have never used a construct such as $val = $val++, I would have
thought that after the assignment, the next operation would have been the
increment. If that were actualy true then I would expect the value to have
incremented by one before the next loop iteration regardless.
A test shows it doesn't, so I'm wrong.
Trying to actualy work out what is going on in the expression in question
makes my brain hurt. It seems that the increment is being discarded
altogether.
Is this actualy an example of undefined behaviour?
Vince Morgan


.



Relevant Pages

  • Re: Postback problem
    ... ur script for popup on click event instead of Page_Load event. ... binding this script code in ItemDataBound this might solve ur problem. ... datagrid to display user records. ... view an images which is displayed in a separate popup window. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: random image display
    ... images randomly and without sequential names. ... script for random image display also at dynamicdrive. ... other slide show producing software. ...
    (microsoft.public.publisher.webdesign)
  • Re: random image display
    ... images randomly and without sequential names. ... script for random image display also at dynamicdrive. ... other slide show producing software. ...
    (microsoft.public.publisher.webdesign)
  • Re: WHILE loop problems
    ... Vince Morgan wrote: ... images to display on a profile page, then put a notice at the bottom. ... It seems that the increment is being discarded ...
    (alt.php)
  • Re: Scripting Problem with IE6 and OE
    ... > message: INTERNET EXPLORER SCRIPT ERROR ... > OE indicates I need to turn scripting on before images will be ... You can, however, keep "Automatically Inline Images" if you set it to 0 or ... This could be useful if you want to totally suppress the display of ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)