number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

number

Post by SidewinderX »

Hello, i have a lyrics database and I want to make a script to display how many lyric records I have. I origionally thought to just dispaly the $id and add one to it since the record starts at 0. But first i just tried just to dispaly $id

Code: Select all

<?php
echo ("We got in our database $id lyrics");
?>
and that yielded 12, although I have more then 12 entries. What am i doing wrong?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Code: Select all

SELECT count(*) FROM lyrics_table;
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Or you could use the PHP command [php_man]mysql_num_rows[/php_man]($query);
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

IE:

Code: Select all

$result = mysql_query("SELECT * FROM --TABLE--");
$num_rows = mysql_num_rows($result);
echo $num_rows;
Post Reply