Jump to content

simple count code


jacko_162

Recommended Posts

Looke on the PHP manual for the "count" function and it has confused me.

 

it seems to count arrays more than anything.

 

i have a small site and i wanted to display how many items are contained within a Database table.

 

for example i want it to count the amount of users are in the user table.

 

and i then need to echo that amount + 100.

 

Can someone help me with the code.

 

i have already included a database connect script within the header of the page with includes etc.

 

Help would be appreciated. but i would like to know how the code works else i will never learn.  ;D

Link to comment
Share on other sites

ok i managed to count the rows and echo that amount.

 

how can i add a number to the echo for example how would i add 100 to the amount and echo the "new" amount?

 

 

here is my working code;

<?php

// Query the DB and perform the count
$result = mysql_query("SELECT * FROM members");
$num_rows = mysql_num_rows($result);

// Display the results
echo $num_rows; 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.