Jump to content

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


Tony-KM

Recommended Posts

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):

[code]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>";[/code]

And here's the code in action - http://www.ffinsight.com/index.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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.