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
49
Other forums
query help
Hi experts.
i have a table rep2 like this
PROD_COD ACCT_NO DUE_DAYS BALANCE
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?
Custom list order
Hi there,
I have checked this tutorial and it's great till the point where I want to display
PHP Blog help
Need help with posting comments in a word press blog? I have a comments page where the comments are
MySQL noob question
hi guys
I have a simple mysql table set up, along the lines of
Col 1 - Col 2 - Date_l
check comment for html
hi, I just wanted to check if a comment a user posts contains HTML, and if it does, to not allow it
Database connection failure
Hello All,
I am trying to create new connection to Oracle DB 10.1,
I could not see a
TabControl Inside ListView Not Editing
Hello everybodyI have a ListView on my page. Inside the ListView I put a TabControl, cuz I want to p
Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re
same querie, or a new one??
Hi guys,
I'm still working on this drop down list. I've got the actual drop down list to wor