Re: This loop is screwed up totally. Why o why o why....

From: Date: Mon, 09 Apr 2001 06:30:25 +0000
Subject: Re: This loop is screwed up totally. Why o why o why....
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-47725@lists.php.net to get a copy of this message
On Mon, 9 Apr 2001 15:12, Yo Bro wrote: > Still no luck. > There should be no reason why this doesn't work. I tried it the way you > tested it, and it doesn't really demonstrate it the same as if using > the (file_exists command. > > When using looking for the images it appears the if statement is > interferring with the loop. This is a nightmare. Freddy would love > this. > > YoBro Hrm; is it then possible that the problem is not within _this_ loop, but perhaps the loop wherein you get the stuff from the DB. Perhaps if you could share the [full/more of the] script?? > > "David Robley" <huntsman@www.nisu.flinders.edu.au> wrote in message > news:01040914425602.26561@www... > > : On Mon, 9 Apr 2001 14:27, Yo Bro wrote: > : > I do have a matching image, and all cases it does work with > : > different records from the database. IE Where there might be an > : > array of 15 items, but it is always the last one that doesn't show. > : > Even if the image is there, because it gets used if i add another > : > value to the array. IE > : > PS|PW|AC|CD > : > > : > In this case all but CD would be displayed. > : > Still no luck. > : > > : > I noticed your code used if (!file_exists > : > Where as I want to check if it does exist. Is your way worth a try? > : > : Had to do that because, of course, I don't have the image files :-) > : You could try it.... > : > : > "David Robley" <huntsman@www.nisu.flinders.edu.au> wrote in message > : > news:01040914213301.26561@www... > : > > : > : On Mon, 9 Apr 2001 13:56, you wrote: > : > : > Hi I have a feild in a MySql database called features. It is > : > : > delimited by | the line above the \ key. > : > : > Anyway, the feild has things like PS|PW|AC etc in it. > : > : > I have the code below to explode that feild. It all works fine, > : > : > but when it comes to looping the code below it always misses > : > : > that last value. (Example - AC) > : > : > Only in the IF statement - if i echo the variable "$feature" > : > : > out of the IF statment it prints the text fine. But i need it > : > : > to check for the existance of a gif first to display in the > : > : > window. As you will see I have gifs with the names and the > : > : > variable $feature ends with .gif > : > : > It works great, but it misses the last value to the array > : > : > $feature. Any ideas. > : > : > > : > : > $specs = $myrow[features]; > : > : > > : > : > $features = explode('|',$specs); //What the feild is > : > : > delimited by '|' reset ($features); > : > : > > : > : > while (list(, $feature) = each ($features)) { > : > : > > : > : > if (file_exists("features/$feature.gif")){ > : > : > echo "<img > src=\"features/$feature.gif\"><br>"; > : > : > echo "$feature"; > : > : > } > : > : > > : > : > } //End While > : > : > > : > : > > : > : > -- > : > : > Regards, > : > : > > : > : > > : > : > YoBro > : > : > : > : This seems to work OK for me: > : > : <?php > : > : $specs = "PS|PW|AC"; > : > : $features = explode('|',$specs); //What the feild is delimited by > : > : '|' reset ($features); > : > : > : > : while (list(, $feature) = each ($features)) { > : > : > : > : if (!file_exists("features/$feature.gif")){ > : > : echo "<img src=\"features/$feature.gif\">"; > : > : echo "$feature<br>\n"; > : > : } > : > : > : > : } //End While > : > : ?> > : > : > : > : Is it possible that you don't hve a matching image for the last > : > : item? > : > : -- > : David Robley | WEBMASTER & Mail List Admin > : RESEARCH CENTRE FOR INJURY STUDIES | > : http://www.nisu.flinders.edu.au/ AusEinet > > : | http://auseinet.flinders.edu.au/ Flinders University, > ADELAIDE, > : SOUTH AUSTRALIA > : > : -- > : PHP General Mailing List (http://www.php.net/) > : To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > : For additional commands, e-mail: php-general-help@lists.php.net > : To contact the list administrators, e-mail: > : php-list-admin@lists.php.net -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#47725) next »