Jump to content

Archived

This topic is now archived and is closed to further replies.

hustler

How to show entries in a table

Recommended Posts

How can we count the number of entries in the table

For example i have a member table, where all the data for members is stored

I want to display in the admin panel that we have this number of members!

How to do it.

Share this post


Link to post
Share on other sites
Hi,

I think the select statement would be something like...

$sql = "SELECT COUNT(*) as Num FROM tablename";

Gerard

Share this post


Link to post
Share on other sites
SELECT COUNT(*) FROM `members`

More info here:
[url=http://www.1keydata.com/sql/sqlcount.html]SQL COUNT[/url] :)

Orio.

Share this post


Link to post
Share on other sites
Thanx for you replies
sorry for being silly
[code]<?php
$query='SELECT COUNT(*) FROM `members`';
$result= mysql_query($query);
echo $result;
?>[/code]

but will this do?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Thanx Mate that worked!

the next question is
We 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]
<?php
require_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>&nbsp;</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"];?>&nbsp;
                    </font>   
                </td>
                <td>
                    <font face=verdana size=2>
                        <?php echo $member["email"];?>&nbsp;
                    </font>   
                </td>               
                <td><font face=verdana size=2><?php echo $member["contact"];?>&nbsp;</td>
                <td><font face=verdana size=2><?php echo $member["username"];?>&nbsp;</td>
                <td><font face=verdana size=2><?php echo $member["postcode"];?>&nbsp;</td>
            </tr>
<?php } ?>           
            <tr>           
                <td colspan=6 align=center><input type=submit value="Delete Selected"></td>
            </tr>               
        </table>
    </form>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.