hustler Posted October 19, 2006 Share Posted October 19, 2006 How can we count the number of entries in the tableFor example i have a member table, where all the data for members is storedI want to display in the admin panel that we have this number of members!How to do it. Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/ Share on other sites More sharing options...
Solarpitch Posted October 19, 2006 Share Posted October 19, 2006 Hi,I think the select statement would be something like...$sql = "SELECT COUNT(*) as Num FROM tablename";Gerard Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/#findComment-111467 Share on other sites More sharing options...
Orio Posted October 19, 2006 Share Posted October 19, 2006 SELECT COUNT(*) FROM `members`More info here:[url=http://www.1keydata.com/sql/sqlcount.html]SQL COUNT[/url] :)Orio. Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/#findComment-111469 Share on other sites More sharing options...
hustler Posted October 19, 2006 Author Share Posted October 19, 2006 Thanx for you repliessorry for being silly[code]<?php$query='SELECT COUNT(*) FROM `members`';$result= mysql_query($query);echo $result;?>[/code]but will this do? Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/#findComment-111478 Share on other sites More sharing options...
hustler Posted October 19, 2006 Author Share Posted October 19, 2006 when i use this i get a output in my page=Resource id #9 Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/#findComment-111480 Share on other sites More sharing options...
craygo Posted October 19, 2006 Share Posted October 19, 2006 you need to retrieve the query.[code]<?php$query='SELECT COUNT(*) FROM `members`';$result= mysql_query($query);$r = mysql_fetch_array($result);echo $r[0];?>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/#findComment-111481 Share on other sites More sharing options...
hustler Posted October 19, 2006 Author Share Posted October 19, 2006 Thanx Mate that worked!the next question isWe have a member list in the admin where the admin can see all the active members.At the moment it displays as a list and we can edit and delete them.What i want at the top is search box where we can enter surname of the member and it display us only ones with that surname.current code is[code]<?phprequire_once("includes/class.member.php");$objMember=new Member(); $arrMemberList=$objMember->getMembers($req_isActive);if(count($arrMemberList)>0){?> <form method=post> <input type=hidden name="form_action" value="delete"> <table cellspacing=0 cellpadding=0 width=90% border=1> <tr> <td> </td> <td><font face=verdana size=3><b>Name</td> <td><font face=verdana size=3><b>Email</td> <td><font face=verdana size=3><b>Contact</td> <td><font face=verdana size=3><b>Username</td> <td><font face=verdana size=3><b>Postcode</td> </tr><?php while($member=array_pop($arrMemberList)){ ?> <tr> <td> <input type=checkbox name=id[] value="<?php echo $member["id"];?>"> <a href='admin.php?c=editMember&mid=<?php echo $member["id"];?>'>Edit</a> </td> <td> <font face=verdana size=2> <?php echo $member["firstname"]." ".$member["lastname"];?> </font> </td> <td> <font face=verdana size=2> <?php echo $member["email"];?> </font> </td> <td><font face=verdana size=2><?php echo $member["contact"];?> </td> <td><font face=verdana size=2><?php echo $member["username"];?> </td> <td><font face=verdana size=2><?php echo $member["postcode"];?> </td> </tr><?php } ?> <tr> <td colspan=6 align=center><input type=submit value="Delete Selected"></td> </tr> </table> </form>[/code] Link to comment https://forums.phpfreaks.com/topic/24468-how-to-show-entries-in-a-table/#findComment-111495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.