adamlacombe Posted July 5, 2009 Share Posted July 5, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/ Share on other sites More sharing options...
seventheyejosh Posted July 5, 2009 Share Posted July 5, 2009 like so? <table> <tr> <td width="50%"> </td> <td width="50%"> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869451 Share on other sites More sharing options...
adamlacombe Posted July 5, 2009 Author Share Posted July 5, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869457 Share on other sites More sharing options...
seventheyejosh Posted July 5, 2009 Share Posted July 5, 2009 link to the site? Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869458 Share on other sites More sharing options...
adamlacombe Posted July 5, 2009 Author Share Posted July 5, 2009 http://media-script.com/index.php Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869461 Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 k here is a theoretical go usually i'd test and upload etc, but i obv dont have ur DB availible 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869485 Share on other sites More sharing options...
adamlacombe Posted July 6, 2009 Author Share Posted July 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869840 Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 awesome 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! Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869848 Share on other sites More sharing options...
adamlacombe Posted July 6, 2009 Author Share Posted July 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869854 Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 Yea, no problem, just drop me a PM or use my AIM or post here and someone will help. And if this issue is resolved, dont forget to hit the Solved button in the bottom right! Quote Link to comment https://forums.phpfreaks.com/topic/164876-solved-two-columns/#findComment-869860 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.