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
"GROUP BY" in arrays
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql
Find only certain URLs from page ... regex (semi-complete script)
Hi guys,
What I need to do is take a page & extract all the URLs from the page &a
Filename like the user name
I am creating a form and storing the values in file. Could anyone please tell me how to write a code
[PHP HELP] Php order form.
Hello to everyone @ phpfreaks. Im new to this site and hope to learn lots of things here.
Fir
batch file not building to webapps folder
Hello. I just started running Vista :P and can't seem to get my projects deployed. I found out how
do while...woes
I'm sure this is childsplay but it is stumping me, everytime i try what I think would make this work
cURL error
So here is my code... I got it off of here... http://www.youtube.com/watch?v=XcgQUsorF_8
Because
a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca
Problem with an browser game.
Hello,i just joined that great forum and i got php prob,its kinda freaky...anyway i got browser game
PHP & MS Access - Line Break
Hey Guys!
I'm pulling records from an MS Access database and listing them using PHP and I'm r