Right, I've (somehow) coded a pretty nifty affiliates system for my site - http://wafflesweb.co.uk/?module=resources&action=affiliates Basically it allows the user to enter their website address, and the link to their banner, and its added to a database. These then get passed through some code, and are echoed back to the same page, as you can probably see if you visit that page. However, I want it to echo them out in to rows and columns..ideally 5 affliates , then go down to the next row. I'm sure this is possible. Here is my code for showing the affiliate banners. PHP: <?php$query="SELECT * from affiliates ";$result=mysql_query($query) or die ("Could not execute query: $q.". mysql_error()); while($row=mysql_fetch_array($result)) //gets all results in table{extract($row); // extract the row and values// leave php, html for formatting banners - this is the code that needs tweaking i think.?><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> //echos the $banner into the table, and assigns the matching $url to it so when its clicked, it goes to their website.</tr></table><?php //back in to php to end the while..} ?> any suggestions? Much obliged.
I've not done this before so I suggest asking at www.sitepointforums.com though maybe this can help? http://www.bloodys.com/phpscripts.php at the end it has some sample code which might help you out, In 2 Rows and In 2 Columns. btw: have you coded the whole site?
The private messenger was followed from a tutorial, and I had to read a user registration tut about ten times, but I think I nailed it now. The affiliates system, the admin control and the "add news" was all coded by myself, and your help.
Got some fast feedback on that site..I was told to create a counter, and put it in the loop, so when the counter = 5, it culls the row, starts a new one. From the other site, the script I found, and my modified version: PHP: <?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); $elcount = count($rowl); $halfel = round($elcount/2); echo "<table width=100%><tr>"; for ($i=1; $i<=$elcount; $i++) { echo "<td width=". round(100/$halfel) ."%><a href=\"$url\" target=\"_blank\"><img src=\"$banner\" width=\"88\" height=\"31\" border=\"0\"></td>"; if ($i==$halfel) { echo "</tr><tr>"; } } echo "</tr></table>"; ?> sounds like it should work...
I've done it. code up there is full of errors and i havent uploaded the working version yet. will do tomorrow and post working code here
PHP: $elcount = count($el);$halfel = round($elcount/2);echo "<table width=100%><tr>";for ($i=1; $i<=$elcount; $i++) {echo "<td width=". round(100/$halfel) ."%>$el[$i]</td>";if ($i==$halfel) { echo "</tr><tr>"; }}echo "</tr></table>"; is the loop code..just taken from that script site. I've discovered it only works with an array...and unless there is a way to put my list of affiliates into an array, I don't believe it will work.