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!


Results 1 to 10 of 10

Thread: PHP Help!

  1. #1
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default PHP Help!

    Right, not sure how to explain, but litterally:
    MYSQL table, news storys:
    Website, "tab display", want 3 most recent stories.
    I know how to list them, but not how to do it with the tabs, because of the way they're coded.. can anyone help me out?

    Here's an idea of what i want, with examples if there was only one
    PHP Code:
    <?php
    $query 
    "SELECT * FROM news where published = '1' ORDER by id DESC LIMIT 3";
    $row_news mysql_fetch_array($query);
    ?>
    <div id="myTabs">
             <ul>
                <li><a href="#firsttab"></a><? echo $row_news['shortstory']; ?></li>
                <li><a href="#secondtab">newsID2</a></li>            
                <li id="last"><a href="#thirdtab">newsID3 </a></li>            
            </ul>
    <div id="firsttab" class="tab_content">
     <div class="rafat">
     <img src="<? echo $row_news['image']; ?>" />
     <p> <? echo $row_news['shortstory']; ?> </p>
     </div>
    </div>
    <div id="secondtab" class="tab_content">
     <div class="rafat">
     <img src="newsIMAGE2" />
     <p> newsSTORY2 </p>
     </div>
    </div>
    <div id="thirdtab" class="tab_content">
     <div class="rafat">
     <img src="newsIMAGE3" />
     <p> newsSTORY3 </p>
     </div>
    </div>
    </div>

  2. #2
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Can you link to the site? I might understand what you mean then

  3. #3
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default


    there's an image of what it looks like

  4. #4
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    so you want the 3 latest news, each one displayed in a separate tab?

  5. #5
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Yeah, that's the one. I've wrote the query, and what the collumns are called in the table in the code

  6. #6
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Make it so each tab fetches a certain news article from the database, I'm guessing when a new one is added it becomes 1, and 1 is pushed down to 2, etc. why not make it so tab 1 fetches news one, and tab two fetches news two, etc?

  7. #7
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Quote Originally Posted by Jaaaack! View Post
    Make it so each tab fetches a certain news article from the database, I'm guessing when a new one is added it becomes 1, and 1 is pushed down to 2, etc. why not make it so tab 1 fetches news one, and tab two fetches news two, etc?

    It doesn't: I've coded it so it just auto increments the ID..
    is ther anyway to do it, so it just orders by ID decesnding?
    or can you even (i'm sure i've seen this somewhere) make it so i run the query, then when defining the tab values, it'd be something like

    tab1 : <? echo $row_news['shortstory']; ?>
    tab2 :
    <? echo $row_news + 1 ['shortstory']; ?>
    tab 3 : <? echo $row_news + 2 ['shortstory']; ?>

    Obviously that's not the correct syntax, but i'm sure i've seen that done before..

  8. #8
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    you could do
    PHP Code:
    for($x 0$x count$row_news ); $x++ )
    {
    echo 
    "<div id=\"tab{$x}\" class=\"tab_content\">
     <div class=\"rafat\">
     <img src=\"
    {$row_news[$x]['image']}\" />
     <p> 
    {$row_news[$x]['shortstory']}</p>
     </div>
    </div>"
    ;

    or something like that. im tired
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  9. #9
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Not sure i can do it like that, because the way the tabs are coded, they don't repeat the same code three times..

  10. #10
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Got it!
    Used arrays to dump the results into
    +rep to yous two

Posting Permissions

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