Jump to content

Help please.


yuws

Recommended Posts

I need help by getting this content to go in rows of 3 horizontal.

 

right now it lines up strait down.

 

Here's the code:

 

<?php include 'functions.php'; ?>
<?php
connect();
$id = mysql_escape_string(intval($_GET['id']));
$query = "SELECT * FROM `users` WHERE `id` = '$id'";
$result = mysql_query($query);
$numrows = @mysql_num_rows($result);
if ($numrows != 0)
{
	$row = mysql_fetch_array($result);
	$name = stripslashes($row['username']);
	$query = "SELECT * FROM favorites WHERE uid='$id'";
	$result = mysql_query($query);
	$numrows = @mysql_num_rows($result);
?>
<table border="0" cellpadding="0" cellspacing="0" width="742px" class="side">
<tr>
	<td class="btitle" valign="top" colspan="2"><?php echo $name; ?>'s Favorites</td>
</tr>
<tr>
	<td align="left" valign="top">
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
<?php
	if ($numrows != 0)
	{
			$dl = "celll";
			$i = 0;
			while ($row = mysql_fetch_array($result))
			{
					$game_id = stripslashes($row['gameid']);
					$q = "SELECT `name`, `description`, `image`, `display` FROM `ava_games` WHERE `id` = '$game_id'";
					$r = mysql_query($q);
					$rw = mysql_fetch_assoc($r);
					$gt = stripslashes($rw['name']);
					$ds = stripslashes($rw['description']);
					$im = stripslashes($rw['image']);
					$display = stripslashes($rw['display']);
					$i++;
					if ($i % 2 == 0)
					{
							$dl = "celll";
					}
					else
					{
							$dl = "celld";
					}
					if ($display)
					{
?>
			<tr>
				<td width="35" height="35" bgcolor="ffffff" class="text"><? echo '<img src="<?php echo $im;?>" alt="" width="90" height="90" />';?>
<font color="#333333"><b>
					<a href="game.php?id=<?php echo $game_id; ?>" class="dlink"><?php echo $gt; ?></a>
					</b></font></td>

<?php
					}
			}
	}
	else
	{
?>
			<tr>
				<td align="center" class="content">
					<br><?php echo itou($id) . " has no favorites yet."; ?>
				</td>
			</tr>
<?php
	}
?>
		</table>
	</td>
</tr>
</table>
<?php
}
else
{
	message("User not found.  Please check the link and try again.");
}
mysql_close();
?>
<?php
?>

 

if anyone could help me fix this, that would be awsome!

Link to comment
Share on other sites

Hi,

 

So you want a table with three columns? OK if I understood properly it works like this. You need to code a little counter for your output. When $count > 3 it resets and starts a new row.

 

<table >

  <tr>

    <td>1</td>

    <td>2</td>

    <td>3</td>

  </tr>

</table>

 

Start you loop with <tr>

Put the results in <td>'s

When the result counter gets to 4 it echo's </tr> and starts the process again.

 

That's the way it works anyway. I coded this once but I don't remember in which file the code lives! The only 'hard' bit if adding the extra empty <td>'s if you have an inconvenient number of results e.g. if you have 10 results you'll need to add two <td> sets to finish the table in a tidy way.

 

HTH

 

Huw

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.