iJoe
07-08-2009, 08:11 PM
Hi,
I'm trying to grab information from one table in the database based on info from another database. That works fine and it's giving out the right results, however. I want the information to be displayed in a table, I currently have this code and it's not working properly so is anyone able to fix it?
Thanks,
Joe
<?php
$result = mysql_query("SELECT * FROM site_game_favs WHERE uid='{$_GET['user']}'") or die(mysql_error());
while($row=mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM site_games WHERE id='{$row['gid']}'") or die(mysql_error());
$row2=mysql_fetch_array($result2);
$tdcount = 1;
$numtd = 3; // number of cells per row
echo "<table>";
$tdcount = 1;
$numtd = 4; // number of cells per row
echo "<table>";
if ($tdcount == 1) echo "<tr>";
echo "<td><div class='right-top'></div><div class='right-mid'><center><img src='http://www.nexdana.com/thumbs/{$row2['img']}' height='50' width='50' style='float:left'> <a href='http://www.nexdana.com/new/?page=load_game&id={$row2['id']}' class='greenlink'> {$row2['name']}</a><br> Added to yout favourites on: {$row['date']}</center></div><div class='right-bot'></div></td>"; // display as you like
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo "</tr>";
}
echo "</table>";
}
?>
(Database is connected to in a different code)
I'm trying to grab information from one table in the database based on info from another database. That works fine and it's giving out the right results, however. I want the information to be displayed in a table, I currently have this code and it's not working properly so is anyone able to fix it?
Thanks,
Joe
<?php
$result = mysql_query("SELECT * FROM site_game_favs WHERE uid='{$_GET['user']}'") or die(mysql_error());
while($row=mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM site_games WHERE id='{$row['gid']}'") or die(mysql_error());
$row2=mysql_fetch_array($result2);
$tdcount = 1;
$numtd = 3; // number of cells per row
echo "<table>";
$tdcount = 1;
$numtd = 4; // number of cells per row
echo "<table>";
if ($tdcount == 1) echo "<tr>";
echo "<td><div class='right-top'></div><div class='right-mid'><center><img src='http://www.nexdana.com/thumbs/{$row2['img']}' height='50' width='50' style='float:left'> <a href='http://www.nexdana.com/new/?page=load_game&id={$row2['id']}' class='greenlink'> {$row2['name']}</a><br> Added to yout favourites on: {$row['date']}</center></div><div class='right-bot'></div></td>"; // display as you like
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo "</tr>";
}
echo "</table>";
}
?>
(Database is connected to in a different code)