PDA

View Full Version : Getting info for other pages *efficiently*


06-26-2000, 05:21 AM
<?php
$mysql_link = mysql_connect("xx.server.net","public","shoutitout");

$query= "select count(userid) from user";
$mysql_result = mysql_db_query("kosforum", $query, $mysql_link);
$numusers = mysql_fetch_array($mysql_result);

$query="select count(threadid) from thread";
$mysql_result = mysql_db_query("kosforum", $query, $mysql_link);
$numthreads = mysql_fetch_array($mysql_result);

$query="select count(postid) from post";
$mysql_result = mysql_db_query("kosforum", $query, $mysql_link);
$numposts = mysql_fetch_array($mysql_result);

$query="select count(sessionid) from session";
$mysql_result = mysql_db_query("kosforum", $query, $mysql_link);
$numonline = mysql_fetch_array($mysql_result);

mysql_close($mysql_link);

print ("<font color=#FFFFFF>Netforum</font> members: ");
echo $numusers['0'];
print (", threads: ");
echo $numthreads['0'];
print (", posts: ");
echo $numposts['0'];
print (", now online: ");
echo $numonline['0'];
?>

This returns:

"Netforum members: 64, threads: 87, posts: 219, now online: 4"

for my tiny little board. ;)

The question is, can't I make that considerably more efficient yet? /me is a casual programmer and has only done some PHP in the past little while.