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
Error in Configure System Landscape Directory phase
Hi
We are getting the error in Configure SLD phase ( 41 of 44 phase).
Please f
Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:
http://www.mydomain.com/directory/index.php
How to display random record from table?
I have the following code:
Code: <?php
$display_block .= "<input type=
MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need
quick question about System Change Number(SCN) in FlashBack Query topic
i know tht we can get the SCN of the database using flashback concept as follows
SQL>
regex for quoted text within a string
I am still getting the hang of regex expressions, but I cant seem to figure out how I would escape q
PHP hyperlinks generator
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500
delete comma
HI,
How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr
Displaying values from a SQL count...
Hi,
Easy enough question i just forget the exact method ..
I have ...
Code: //count win
replacements
I have a variable in my PHP script like
ASSFDDDDDDDDDDDDDASDDDDDDDDARYTRHKKHHHHHHHHHHH and p