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
https://forums.phpfreaks.com/topic/213826-simple-count-code/
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
https://forums.phpfreaks.com/topic/213826-simple-count-code/#findComment-1112866
Share on other sites

Archived

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

×
×
  • 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.