Jump to content


Photo

Automaticall adding </tr><tr> after so many SQL retrievals?


  • Please log in to reply
2 replies to this topic

#1 Tony-KM

Tony-KM
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationEngland

Posted 12 July 2006 - 09:39 PM

Ok I've checked on both the site and forum here for help on this but since I don't know exactly what the help is I'm looking for, I didn't really know where to look for it. Ok, here's the low-down, I've been working on an image database of sorts (to be used for free avatars, signatures, and later a simple screenshot gallery) using SQL for my site. Now, that works fine, but I'm getting the script to insert each image (avatars at the moment) into seperate cells in the table, and it causes the page to stretch nastilly once there's more than 5 cells side by side. What I need is a way to tell the script to automatically add "</tr><tr>" after every 5th entry into the table.

Here's the script as it looks (so that it makes more sense, and yes I know the code is slightly messy, but meh, I'm not bothered about coding aesthetics at the moment):

echo "

<table width=\"100%\" cellpadding=\"0\" cellspacing=\"1\">
<tr>";

while ($row=mysql_fetch_array($result))
{

$id=$row["id"];
$name=$row["name"];
$artist=$row["artist"];
$artisturl=$row["artisturl"];
$series=$row["series"];
$category=$row["category"];
$date=$row["date"];
$previewimage=$row["previewimage"];
$download=$row["download"];
$viewhtml=$row["viewhtml"];

echo "

<td width=\"100px\"><center><img src=\"$previewimage\" border=\"1px solid #000000\"><br>by $artist</center></td>";

} 

echo "
</tr></table>
<br><br>
<center>";

And here's the code in action - http://www.ffinsight...dex.php?icon=10

Now I know I could switch the $row variable to be 5, but that means I could only display 5 avatars per page, and I want to display 25, and the page only looks right if I have 5 avatars lined next to each other. Any help on this would be greatly appreciated.

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 12 July 2006 - 09:43 PM

http://www.phpfreaks....html#msg394657
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Tony-KM

Tony-KM
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationEngland

Posted 12 July 2006 - 09:51 PM

Thank you so much! I'd kiss you if that weren't weird.

I should have thought of something like that, I had to do something almost identical for a Flash project I did in university this year >.<

Thanks again you've saved me much killing of people.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users