I could do with a hand i am trying so stack my images on this page ( see my sig) in the shape of a pyramid so when someone ads a foot image the image will be display 1 on row 1, 2 on row 2, 3 on row 3 and so on until row 20 where they will just be laid next to each other as that is the maxi can show in a row. I would also like them to be shown randomly in no particular order. if any could help that would be great the code i have now is to display the images goes like this // Use the result while ($res = mysql_fetch_array($result)) { $resu[] = $res; } // Now we free up the result mysql_free_result($result); foreach ($resu AS $row) { echo "<a href='".$row['address']."' onMouseover=\"ddrivetip('".$row['description']."')\"; onMouseout=\"hideddrivetip()\"target=\"_blank\"><img src='feet/".$row['colour']."".$row['leftright'].".jpg' border='0'/></a> "; }
// $resu array contains all images loaded from mysql query // randomize order shuffle($resu); // per line starts at 1 $perLine = 1; $onLine = 0; // go through array foreach ( $resu as $row ) { // do we need a new line? if ( $onLine == $perLine ) { echo '<br />'; // reset counters $onLine = 0; $perLine = ( $perLine < 20 ) ? $perLine+1 : 20; } echo ShowImage($row); $onLine++ } PHP: (untested) Does that help? I've used ShowImage() for readability - you can either create that function or put it back to echoing the HTML.
cheers that looks about right but what is that displaying just the basic results not the color of the foot and if it is left or right sorry to be a pain
ah i see it is loading the results from the database right. but i will need to add the mouse over effect to each image as this is part of the sites feature for the links
The whole thing then: // Use the result while ($res = mysql_fetch_array($result)) { $resu[] = $res; } // Now we free up the result mysql_free_result($result); // randomize order shuffle($resu); // per line starts at 1 $perLine = 1; $onLine = 0; // HTML for showing each result function showImage($row) { return <<<EOF <a href="{$row['address']}" onMouseover="ddrivetip('{$row['description']}');" onMouseout="hideddrivetip()" target="_blank"><img src="feet/{$row['colour']}.{$row['leftright']}.jpg" border="0" /></a> EOF; } // go through array foreach ( $resu as $row ) { // do we need a new line? if ( $onLine == $perLine ) { echo '<br />'; // reset counters $onLine = 0; $perLine = ( $perLine < 20 ) ? $perLine+1 : 20; } echo showImage($row); $onLine++ } PHP: Should work, might be the odd typo though.