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 6 of 6
  1. #1
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default Quick MySQL Question...

    Ok so it sounds nooby but...

    How would I fetch the number of rows from a database, if I wanted to see how many rows include the word "admin" within its tables.?

    Its hard to explain lol but I wanna see how many tables have the word "admin" in them? Can someone help me with the mysql query please?

    I thought it would be some like
    mysql_num_rows(mysql_query("SELECT '$username' FROM `table`"));
    But obvs not... HELP? lol,

    Thanks lol

    Lew.
    Last edited by LMS16; 21-02-2010 at 12:53 PM.
    Im not here to be loved, I love to be hated :-}


  2. #2
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    It would probably be something like:

    PHP Code:
    $query mysql_query("SELECT * FROM `table` WHERE `whatever the row is` = `Admin`");
    $query mysql_num_rows("$query"); 
    Not entirely sure but, hope that helps

  3. #3
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    No I mean Ive got a table and it has different tables inside that such as "tta, ttb, ttc ect..." and I want to find how many of those tables have the users username in it so for example, "tta='admin', ttb='admin'" so the number of rows would be 2...

    Lew.
    Im not here to be loved, I love to be hated :-}


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

    Latest Awards:

    Default

    Could try

    PHP Code:
    <?php
    $query 
    mysql_query("SELECT * FROM `table`");

    $count 0;
    while( ( 
    $fetch mysql_fetch_assoc$query ) !== false )
    {
        foreach( 
    $fetch as $key => $value )
        {
            ( 
    $value == "admin" ) ? $count++: false;
        }
    }

    echo 
    $count;
    ?>
    Try that.

  5. #5
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    This might help if you are trying to select the same named column from multiple tables, http://stackoverflow.com/questions/4...-but-different

  6. #6
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Hmmm,, basically I'm making a timetable script and I want to be able to tell the user how many shows they have booked that week...

    Anyone care to explain in a little more details cos me minds gone blank and I cant think of a way... S:S:S:S

    Lew.
    Im not here to be loved, I love to be hated :-}


Posting Permissions

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