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
https://forums.phpfreaks.com/topic/106694-help-please/
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
https://forums.phpfreaks.com/topic/106694-help-please/#findComment-547171
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.