Help with looping


Posted on 16th Feb 2014 07:03 pm by admin

I have a comma separated list of colors taken from a database ($ICo) and a directory of images named "color". The images are named the "color.jpg"
I am attempting to loop through this list and display the corresponding image from the directory in a table with the color name below it.
I am unable to get it to loop through the list, it displays the correct number of images but they are all the first image with the name under it.
The script I have at this stage is
Did you know?Explore Trending and Topic pages for more stories like this.
Code: $columns = 5;
$Color = "$ICo";
$col = explode(",", $Color);
$num = count($col)-1;

echo "<table border='0' cellspacing='2' cellpadding='0'>n";
for($i = 0; $i < $num; $i++) {
if($i % $columns == 0) {
echo "<tr>n";
}
$Name = $col[0];
$pic = "../store/color/$Name.jpg";}
echo "<td align="center" valign="top" width="70" ><img src="$pic" name="$Name" border="1" width="68" height="36">
$Name</td>n";
while ($num >= $col);
if(($i % $columns) == ($columns - 1) || ($i + 1) == $num) {
echo "</tr>n";
}
echo "</table>n";

I have spent hours trying to figure out where I am going wrong.
I know the line "$Name = $col[0];" is incorrect, could somebody please point me in the right direction
No comments posted yet

Your Answer:

Login to answer
101 Like 49 Dislike
Previous forums Next forums
Other forums

Concatenate two strings ???
I have string one $string1 and another $string2.

How to concatenate (add) both of them $str

Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
OK, I think but have a problem, only 1 pro

pointer 102 question
I read a book
1
2
3
4
5
6
7
8
9
10
11
12
int main() {

Async WSAConnect failed on XP with error code = 2 ("File not found")
Hi all,

I have very strange bug, please help me if you can.

It is reproduced o

media recovery
Hi,
i startup the database i got the error

SQL> startup
ORACLE instance started.

help with multi-update
Now sure how to ask this really....
10g database if that matters.

I have a customer

Best PHP Documentation generator
Hello guys!

I would like to hear from you what is the best PHP documentation generator. Perso

RFQ Configuration - can you make PLANT field an optional field in ME42
Is there a way to make the plant field on an RFQ optional in change mode (ME42)?

split string
Hi all

i have some names (imploded by comma):
Code: toronto,paris,madrid
Now, i would

Login Control?!
I have a Web Site that uses the login control also I have set the destinationurl to the page I want

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash