Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Showing how many rows in a table?

Codes here !

Moderators: macek, egami, gesf

Showing how many rows in a table?

Postby webwired » Sat Nov 23, 2002 5:27 pm

Here is the code I am trying to use to print the number of rows that are in a table, but as you are probably laughing right now, you can see that it isn't working... any help will be most appreciated.

<?php
include_once "ez_sql.php";
$query = dbase_numrecords
$result = mysql_query ($query);
print ("$result");
?>
User avatar
webwired
New php-forum User
New php-forum User
 
Posts: 26
Joined: Sat Nov 23, 2002 5:20 pm
Location: St. Louis, Missouri

Re: Showing how many rows in a table?

Postby Oleg Butuzov » Sun Nov 24, 2002 3:46 am

Code: Select all
 <?php

$query = mysql_query("SELECT *FROM `sometable`")
$numrows=mysql_num_rows($query);
echo $numrows;

 ?>


another solution

Code: Select all
$query = "select count(*) from base";
$r=mysql_db_query($database,"$query");
$count = mysql_result($r,0,"count(*)");
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Thank you

Postby webwired » Sun Nov 24, 2002 9:43 am

This is the final functional code:
Code: Select all
   
    <?php
    include_once "ez_sql.php";
    $result = mysql_query("SELECT * FROM quickinfo");
    $num_rows = mysql_num_rows($result);
    echo "$num_rows Customers\n";
    ?>
User avatar
webwired
New php-forum User
New php-forum User
 
Posts: 26
Joined: Sat Nov 23, 2002 5:20 pm
Location: St. Louis, Missouri

Postby Oleg Butuzov » Mon Nov 25, 2002 2:11 am

YES
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron