Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default counting mysql ?

    pm'ed this to som1 but 'he/she' is offline now.

    i need help

    whats the mysql code to count how many things i have in my database ?

    ex: i have a database called Folio with a table called content

    in that table are my designs i posted.

    now i want a code that gives me this;

    There are ... designs

    ... would be how many designs are in there.

    atm i got this;



    PHP Code:
    <? 
    include("config.php"); 

    $select mysql_query("SELECT * FROM `content`"); 
    $get mysql_num_rows($select); 

    echo(
    "There are $get designs"); 
    ?>
    but i get this error:


    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/olivierp/public_html/Folio/count.php on line 5
    There are designs

    Thanks, oli

  2. #2
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Whats the name of the variable you assigned the mysql_connect to? (e.g if it was $mysql your code would be

    PHP Code:
    <? 
    include("config.php"); 

    $select mysql_query("SELECT * FROM `content`"$mysql); 
    $get mysql_num_rows($select); 

    echo(
    "There are $get designs"); 
    ?>
    Last edited by Tomm; 12-11-2006 at 12:51 PM.

  3. #3
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default

    Quote Originally Posted by Teaspoon View Post
    Whats the name of the variable you assigned the mysql_connect to? (e.g if it was $mysql your code would be

    PHP Code:
    <? 
    include("config.php"); 

    $select mysql_query("SELECT * FROM `content`"$mysql); 
    $get mysql_num_rows($select); 

    echo(
    "There are $get designs"); 
    ?>

    I will check, and thanks for helping

    EDIT=

    $connect = mysql_connect( ... and so on

    so its $connect i asume ?

    2ND EDIT:

    with;
    PHP Code:
    <?  
    include("config.php");  

    $select mysql_query("SELECT * FROM `content`"$connect);  
    $get mysql_num_rows($select);  

    echo(
    "There are $get designs");  
    ?>
    i get same error:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/olivierp/public_html/Folio/count.php on line 5
    There are designs
    Last edited by [Oli]; 12-11-2006 at 12:56 PM.

  4. #4
    Join Date
    Aug 2005
    Posts
    856
    Tokens
    0

    Default

    Make sure spellings are all correct... in my site i use:

    PHP Code:
    $new mysql_query("select * from users"); 
    $new mysql_num_rows($new); 
    And that counts how many members there are fine... yours looks the same as mine so its weird....

  5. #5
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by [oli] View Post
    I will check, and thanks for helping

    EDIT=

    $connect = mysql_connect( ... and so on

    so its $connect i asume ?

    2ND EDIT:

    with;
    PHP Code:
    <?  
    include("config.php");  

    $select mysql_query("SELECT * FROM `content`"$connect);  
    $get mysql_num_rows($select);  

    echo(
    "There are $get designs");  
    ?>
    i get same error:
    You do not need the $connect bit.

    what are the rows in ur content table?

    Coz im thinking u MIGHT need to do an array...

    Try this:

    PHP Code:
    <?
    include("config.php");
    $selecter mysql_query("SELECT * FROM `content`");  
    while (
    $select mysql_fetch_array($selecter)){
    $get mysql_num_rows($select);  
    echo(
    "There are $get designs");  
    }
    ?>

    Tell me if it works
    Last edited by Jackboy; 12-11-2006 at 02:18 PM.

  6. #6
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default

    your codes dont work; i editted my code to this;

    PHP Code:
    <?  
    include("config.php");  

    $select mysql_query("SELECT * FROM `content`");  
    $array[]=@mysql_num_rows($select);
    if (
    count($array)==0)
    echo(
    "There are no designs");

    echo(
    "There are $select designs");
    ?>
    I dont get error now, but it doesnt show an ammount i just get

    There are designs

  7. #7
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    My one doesn't work :S ;o

Posting Permissions

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