I am having problems getting my script to display 3 items in a row. The script is supposed to fetch items from a database that have been inputted by users and display them, it does however it will only display 1 item in a row and I don't know what I am doing wrong? Can someone help me on how to display said 3 items?
<?php
include('config.php');
function dehtml($html)
{
return htmlentities($html, ENT_QUOTES, 'utf-8');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css">
<title>YearBook</title>
</head>
<body>
<div id="wrapper">
<div id="header">
<a href="index.php" id="logo"></a>
<?php
//We check if the admin is trying to log in
if(isset($_POST['password']))
{
//Password verification
if(strtolower($_POST['password'])==strtolower($password))
{
echo '<div class="connexion">You are successfully logged in.</div>';
$_SESSION['logged'] = true;
}
else
{
echo '<div class="connexion">The password is incorrect.</div>';
}
}
//We display a subscribtion link
?>
<div id="nav">
<li><a href="new.php" id="input"></a></li>
<li><a href="photos.php" id="photosactive"></a></li>
<li><a href="index.php" id="welcome"></a></li>
</div>
<div id="phttxt"></div>
<?php
//We get the number of pages
$req1 = mysql_fetch_array(mysql_query('select count(id) as nb from yearbook where status="ok"'));
//We get the current page
if(isset($_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page = 1;
}
//We calculate the number of pages and we display pages links
$nbpages = ceil($req1['nb']/$nb_site_page);
if($page<1 or $page>$nbpages)
{
$page = 1;
}
$pages_site = '<div id="page">Pages:</div> ';
if($page>1)
{
$pages_site .= '<a href="?page='.($page-1).'"><div id="pageno">Previous</div></a> ';
}
for($i=1;$i<=$nbpages;$i++)
{
if($i==$page)
{
$pages_site .= '<strong><div id="pageno">'.$i.'</div></strong> ';
}
else
{
$pages_site .= '<a href="?page='.$i.'"><div id="pageno">'.$i.'</div></a> ';
}
}
if($page<$nbpages)
{
$pages_site .= '<a href="?page='.($page+1).'"><div id="pageno">Next</div></a>';
}
?>
<div id="photospacer"></div>
<tr>
<td colspan="3" class="pages"><?php echo $pages_site; ?></td>
</tr>
<?php
//We calculate the first and last message position to display
$first_message = ($page-1)*$nb_site_page;
$last_message = $first_message +$nb_site_page;
$i = $first_message ;
//On affiche les sites
$req2 = mysql_query('select id, banner, votes from yearbook where status="ok" order by votes desc limit '.$first_message .','.$last_message);
while($dnn2 = mysql_fetch_array($req2))
{
$i++;
?>
<tr>
<?php
//Admin Verification
if($_SESSION['logged']==true)
{
?>
<a href="accept_reject.php?id=<?php echo $dnn2['id']; ?>&ch=s" style="font-size:16px;">Delete this Photo</a>
<?php
}
?>
<table width="600px">
<tr>
<td>
<li><a href="<?php echo dehtml($dnn2['url']); ?>" style="color:#0000ff;text-decoration:underline;font-weight:bold;"><?php echo dehtml($dnn2['name']); ?></a><br />
<br />
<div style="text-align:center;"><img src="<?php echo dehtml($dnn2['banner']); ?>" alt="<?php echo dehtml($dnn2['name']); ?>" style="width:300px;height:150px;" /></div>
<div id="voteno"><?php echo $dnn2['votes']; ?></div><br /><a href="vote.php?id=<?php echo $dnn2['id']; ?>" id="vote"></a></li></td>
</tr>
</table>
<?php
}
//We display pages site (again)
?>
<?php
//Admin Verification (Again)
if($_SESSION['logged']==true)
{
//We display a link to reset votes
?>
<div style="text-align:right;margin-right:20px;"><a href="reset.php">Reset votes</a></div>
<?php
}
?>
<?php
//Admin Verification (Yep and again)
if($_SESSION['logged']==true)
{
?>
<h1>Admin</h1>
<table class="topsite" cellpadding="0" cellspacing="0">
<tr>
<th class="site_th">Photo</th>
<th class="votes_th">Votes</th>
<th class="accept_reject_th">Accept/Reject</th>
</tr>
<?php
//We display new photos(to aprove or reject)
$i = false;
$req2 = mysql_query('select id, url, name, description, banner, votes from yearbook where status!="ok"');
while($dnn2 = mysql_fetch_array($req2))
{
$i = true;
?>
<tr>
<td class="site"><a href="<?php echo dehtml($dnn2['url']); ?>" style="color:#0000ff;text-decoration:underline;font-weight:bold;"><?php echo dehtml($dnn2['name']); ?></a><br />
<?php echo dehtml($dnn2['description']); ?><br />
<a href="<?php echo dehtml($dnn2['url']); ?>" style="color:#008000;"><?php echo dehtml($dnn2['url']); ?></a>
<div style="text-align:center;"><a href="<?php echo dehtml($dnn2['url']); ?>"><img src="<?php echo dehtml($dnn2['banner']); ?>" alt="<?php echo dehtml($dnn2['name']); ?>" style="max-width:500px;max-height:200px;" /></a></div></td>
<td class="votes"><?php echo $dnn2['votes']; ?><br /><a href="vote.php?id=<?php echo $dnn2['id']; ?>" id="vote"></a></td>
<td class="accept_reject"><a href="accept_reject.php?id=<?php echo $dnn2['id']; ?>&ch=a">Accept</a><br /><a href="accept_reject.php?id=<?php echo $dnn2['id']; ?>&ch=r">Reject</a></td>
</tr>
<?php
}
if(!$i)
{
?>
<tr>
<td colspan="3">There are no photos waiting for approval.</td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
?>
</div>
<div id="footer">
<br/>
<li>Made in one night by Woolley and
<a href="#" onclick="document.getElementById('administration').style.display='block';">Saidani.</a>
<li><form action="<?php echo $url_yearbook; ?>" method="post" id="administration" style="display:none;">
<label for="password">Password:</label><input type="password" name="password" id="password" /><input type="submit" value="Log in" />
</form></li>
<?php
}
?>
On  of course.
</div>
</div>
</body>
</html>