Right I've coded up a little affiliates system for users on my site, that enables them to add the their website URL and a direct link to an image. It then spits it back out as an affiliate with the URL attached on my Affiliates page.
Below is my code for displaying the banners.
As of now, each banner is echoed into its own table, and it goes one affiliate to a row..if you can visualise that?
I want ideally, 5 affiliates to a row, then the row is culled, and a new one is started, and so forth until all banners are displayed.
The code:
<?php
$query="SELECT * from affiliates ";
$result=mysql_query($query) or die ("Could not execute query: $q.". mysql_error());
while($row=mysql_fetch_array($result))
{
extract($row); // extract row values
// exit php, html for a table the correct size of a banner, echo the banner and the matching ID. this needs changing, i believe.
?>
<table width="88" height="31" border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="center">
<?php echo "<a href=\"$url\" target=\"_blank\"><img src=\"$banner\" width=\"88\" height=\"31\" border=\"0\">";?></td>
</tr>
</table>
<?php
} // back in to php and end while statement
?>
My only suggestion on how to accomplish this is to add a counter inside the loop, so when it equals 5, to cull the row and start a new one.
I have no idea where to start modifying that code to do this, any help greatly appreciated.
http://wafflesweb.co...tion=affiliates is the link, if you need to clarify what I mean...
Thanks
Edited by Waffles, 28 November 2005 - 03:58 PM.
