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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.