Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1541 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Echoing Number of Values in MySQL Table

Thread title: Echoing Number of Values in MySQL Table
Closed Thread    
    Thread tools Search this thread Display Modes  
07-10-2008, 10:48 AM
#1
Seb is offline Seb
Seb's Avatar
Status: Watermelon Man
Join date: Nov 2006
Location: London
Expertise:
Software:
 
Posts: 3,312
iTrader: 36 / 100%
 

Seb is on a distinguished road

  Old  Echoing Number of Values in MySQL Table

I'm useless at PHP, but could anyone tell me how to echo the number of fields in a MySQL table?

Eg. I have 1800 entries in the table, I want to be able to echo the value "1800".

I'd be very grateful

Sorry if this is vague, but let me know any questions.

07-10-2008, 11:42 AM
#2
aboyd is offline aboyd
aboyd's Avatar
Status: Junior Member
Join date: Jan 2006
Location: USA
Expertise:
Software:
 
Posts: 38
iTrader: 0 / 0%
 

aboyd is on a distinguished road

Send a message via AIM to aboyd

  Old

$query = 'SELECT count(*) FROM tablename';
$result = mysql_query($query);
list($tally) = mysql_fetch_row($result);
echo $tally;

07-10-2008, 12:26 PM
#3
Seb is offline Seb
Seb's Avatar
Status: Watermelon Man
Join date: Nov 2006
Location: London
Expertise:
Software:
 
Posts: 3,312
iTrader: 36 / 100%
 

Seb is on a distinguished road

  Old

Originally Posted by aboyd View Post
$query = 'SELECT count(*) FROM tablename';
$result = mysql_query($query);
list($tally) = mysql_fetch_row($result);
echo $tally;
Thanks, works like a dream - http://www.codedpreview.com

07-10-2008, 06:43 PM
#4
Immersion is offline Immersion
Status: Senior Member
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 918
iTrader: 5 / 100%
 

Immersion is on a distinguished road

  Old

You probably dont need to count * (wildcard) It would probably be faster if you just select one column such as ID which will be indexed. This should decrease the load and make it faster to execute. Just a thought.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed