Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Nov 2006
    Location
    Liverpool/Manchester
    Posts
    2,457
    Tokens
    0

    Latest Awards:

    Default Need help with this

    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 Code:
    <?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>&nbsp;</td>"
     
    $tdcount++; 
     } 
     echo 
    "</tr>"

    echo 
    "</table>";

    }
    ?>
    (Database is connected to in a different code)
    Joe


  2. #2
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Wont the connection to the database have to be included in that code as well though?

  3. #3
    Join Date
    Nov 2006
    Location
    Liverpool/Manchester
    Posts
    2,457
    Tokens
    0

    Latest Awards:

    Default

    It's on the same page, just above that which is why it's not shown Don't worry, that parts working fine. The current output I'm getting is this...

    Joe


  4. #4
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by iJoe View Post
    It's on the same page, just above that which is why it's not shown Don't worry, that parts working fine. The current output I'm getting is this...

    What is it meant to look like?

  5. #5
    Join Date
    Nov 2006
    Location
    Liverpool/Manchester
    Posts
    2,457
    Tokens
    0

    Latest Awards:

    Default

    I want it to be in a table, 3 across and however many down. Obviously it will vary by the amount of results
    Joe


  6. #6
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    its because you're echoing the table code after the mysql_fetch_array which means for each row it'll make a <table>, put that BEFORE the query and it should work

  7. #7
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by RichardKnox View Post
    its because you're echoing the table code after the mysql_fetch_array which means for each row it'll make a <table>, put that BEFORE the query and it should work
    When he does <table>, there is nothing above it that echos. Also when he echo's <table>, it's not in the loop.. so that doesn't matter.

    I think you're misinformed of how tables work.

    Every loop iteration, you're creating a new row.



    So of course it's going to go on top of each other, instead of side by side if you'e creating a new ROW each time it goes through.

    So why not style it via CSS, instead of tables.. and have it float: left; position: relative; display: block; I think.. and it should make it go...

    [] [] [] []
    [] [] [] []
    [] [] [] []

    all depending on what you're width is set at..

    If someone a lot better at CSS could chime in, that would help

  8. #8
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    When he does <table>, there is nothing above it that echos. Also when he echo's <table>, it's not in the loop.. so that doesn't matter.

    I think you're misinformed of how tables work.

    Every loop iteration, you're creating a new row.



    So of course it's going to go on top of each other, instead of side by side if you'e creating a new ROW each time it goes through.

    So why not style it via CSS, instead of tables.. and have it float: left; position: relative; display: block; I think.. and it should make it go...

    [] [] [] []
    [] [] [] []
    [] [] [] []

    all depending on what you're width is set at..

    If someone a lot better at CSS could chime in, that would help
    Just have a div which width is e.g 930px width then have the things inside at 300px wide with 10px margin to the right, and all you need is float: left;

  9. #9
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    My mistake, mis-read the code at 2AM this morning

  10. #10
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by RichardKnox View Post
    My mistake, mis-read the code at 2AM this morning
    I just realized I quoted you when I said you was misinformed of how tables worked.. I didn't mean that aimed at you, meant it aimed at the original poster haha. I was just telling you the <table> wasn't in a loop

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •