Jump to content

[SOLVED] Two columns


adamlacombe

Recommended Posts

I have looked every where for a two column table, Im not sure if what I am saying is what I want, I think it would be better if I said what it looks like..

I want something like this:

http://gameflashme.freehostia.com/

 

I have tried and tried again to basically take and copy the source code and fix it up for my needs but I cant seem to get it to work.

Any tutorials out there that anyone knows of or can someone please just write a basic example!?

 

Thanks in advanced!

Link to comment
Share on other sites

lol, I know it seems easy but my mind tries to think to hard.

I have this:

<?
$r="SELECT * FROM game_cat ORDER BY RAND() LIMIT 0,10";
$r2=mysql_query($r) or die("Could not get cats");
while($row=mysql_fetch_array($r2))
{
echo'<table>
     <tr><td width="50%"><center><b>'.$row['cat_name'].'</b></center><hr>';

$variable1=$row['cat_name'];

$game="Select * FROM game WHERE game_cat='$variable1' LIMIT 0,5";

$game2=mysql_query($game) or die("Could not get games");

while($game3=mysql_fetch_array($game2))
{

echo'<tr align="left" valign="top">
<td align="left" width="71"><span>
<a href="index.php?action=game&id='.$game3[game_id].'">';

if($game3[game_type] == h){
echo'
        <img src="games/thumbs/'.$game3[game_thumb].'" height="71" width="71" />';
}else{
echo'
        <img src="'.$game3[game_thumb].'" height="71" width="71" />';
}

echo'</a>
<br />
</span>
</td>
<td>
<a href="index.php?action=game&id='.$game3[game_id].'">'.$game3[game_name].'</a>
<br />
<small>Played '.$game3[game_views].' Times</small>
</td></tr>';
}
echo'</td>';
}
?>





<?
$r="SELECT * FROM game_cat ORDER BY RAND() LIMIT 0,10";
$r2=mysql_query($r) or die("Could not get cats");
while($row=mysql_fetch_array($r2))
{
echo'<td width="50%"><center><b>'.$row['cat_name'].'</b></center><hr>';


$variable1=$row['cat_name'];

$game="Select * FROM game WHERE game_cat='$variable1' LIMIT 0,5";

$game2=mysql_query($game) or die("Could not get games");

while($game3=mysql_fetch_array($game2))
{

echo'<tr align="left" valign="top">
<td align="left" width="71"><span>
<a href="index.php?action=game&id='.$game3[game_id].'">';

if($game3[game_type] == h){
echo'
        <img src="games/thumbs/'.$game3[game_thumb].'" height="71" width="71" />';
}else{
echo'
        <img src="'.$game3[game_thumb].'" height="71" width="71" />';
}

echo'</a>
<br />
</span>
</td>
<td>
<a href="index.php?action=game&id='.$game3[game_id].'">'.$game3[game_name].'</a>
<br />
<small>Played '.$game3[game_views].' Times</small>
</td></tr>';
}
echo'</td>
     </tr>
</table>';
}
?>

 

And it is not working. Im fine with the PHP but im lost with HTML at this point.  :D

Link to comment
Share on other sites

k here is a theoretical go :D usually i'd test and upload etc, but i obv dont have ur DB availible :D

 

here goes, i'll check the link if u up it.

 


<?

echo "<table>";
echo "<tr><td colspan=2 width=50% align=center>Games</td></tr>\n";

$a=0;

$row=mysql_query("SELECT * FROM game_cat ORDER BY RAND() LIMIT 0,10") or die ("Could not get cats");
while($row=mysql_fetch_array($res)){
$cat=$row['cat_name'];

if ($a=='0'){echo "<tr>";}

echo "<td width=50%>";
echo "<table>";
echo "<tr><td align=center colspan=2><b>$cat</b></center><hr></hr></td></tr>";

$res2=mysql_query("Select * FROM game WHERE game_cat='$cat' LIMIT 0,5") or die("Could not get games");
while($row2=mysql_fetch_array($res2)){
	$id=$row2['game_id'];
	$views=$row2['game_views'];
	$name=$row2['game_name'];
	$thumb=$row2['game_thumb'];
	$type=$row2['game_type'];

	if($type=='h'){
		$image="<img src='games/thumbs/$thumb' height='71' width='71' />";
		}else{
			$image="<img src='$thumb' height='71' width='71' />";
			}

	echo "<tr>";
	echo "<td width=50%><a href=index.php?action=game&id=$id>$image</a></td>";
	echo "<td width=50%><a href=index.php?action=game&id=$id>$name</a><br />Played $views Times</td>";
	echo "</tr>";

	}//end while

echo "</table>";
echo "</td>";

$a++;

if ($a=='2'){echo "</tr>";$a=0;}

}//end while

echo "</table>";

?>

Link to comment
Share on other sites

Ok I uploaded it and fixed one mistake with a query so I got this now:

<?

echo "<table align='center'>";
echo "<tr><td colspan='2' width='50%' align='center'>Games</td></tr>\n";

$a=0;

$res=mysql_query("SELECT * FROM game_cat LIMIT 0,10") or die ("Could not get cats");
while($row=mysql_fetch_array($res)){
   $cat=$row['cat_name'];
   
   if ($a=='0'){echo "<tr>";}
   
   echo "<td width='50%'>";
   echo "<table>";
   echo "<tr><td align='center' colspan='2'><b>$cat</b></center><hr></hr></td></tr>";
      
   $res2=mysql_query("Select * FROM game WHERE game_cat='$cat' LIMIT 0,5") or die("Could not get games");
   while($row2=mysql_fetch_array($res2)){
      $id=$row2['game_id'];
      $views=$row2['game_views'];
      $name=$row2['game_name'];
      $thumb=$row2['game_thumb'];
      $type=$row2['game_type'];
      
      if($type=='h'){
         $image="<img src='games/thumbs/$thumb' height='71' width='71' />";
         }else{
            $image="<img src='$thumb' height='71' width='71' />";
            }
      
      echo "<tr>";
      echo "<td width='50%'><a href=index.php?action=game&id=$id>$image</a></td>";
      echo "<td width='50%'><a href=index.php?action=game&id=$id>$name</a><br />Played $views Times</td>";
      echo "</tr>";
      
      }//end while
   
   echo "</table>";
   echo "</td>";
   
   $a++;
   
   if ($a=='2'){echo "</tr>";$a=0;}
   
   }//end while

echo "</table>";

?>

 

It works perfect! Thanks!

But one problem.. When there isnt as much games in one category then I think it messes it up a little..

Is there something that would fix that in the HTML or PHP?

 

Thanks again, I would have never been able to do that  :D

Link to comment
Share on other sites

awesome :D

 

as far as the formatting, that'd prolly be a CSS issue, and I am def. not the person to ask about that kind of stuff. If u wanna try figuring it out yourself, I'd throw some mock entries into your DB to overload one category of game, then put the "border=1" or style="border:1px solid;" on your master table and try to see what is changing things up.

 

Again though, I just gave you basic formatting, I'd try to google around on css alignment stuff, or just ask your new question in the CSS board here.

 

Good Luck!

 

 

Link to comment
Share on other sites

Thats ok, I kinda fixed it, I just removed category's that there are no games and limited it to one game until I add more.

Thank you again for the help.

I am going to try and add what you gave me to the browsing pages.

If it becomes a problem because of the paging (page: 1,2,3)  issue, you mind helping?

Kinda just learning all this new stuff, im 15 and been working with PHP for a while but never this intense.  :D

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.