Count Male And Female Online
Started on the old forum in July 2008 · view the original in the archive · old links redirect here
TL;DR · summary of 35 replies
- - The issue was about counting Male and Female users online in an ONLINE MENU.
- - The code approach involved using JOIN to combine ibwf_online and ibwf_users tables for accurate counts of male and female users.
- - A solution was provided by Guest, suggesting a modification to the index.php file for better handling of page jumpers.
Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.
very easy bro ... i'm very no0b to combine mySQL only ... haha
paste your code here for BOYZONE or you wont get any help form me next time
Try This
😈 😈 😈
echo "Online Stats"; echo " "; echo "Users: <a href="index.php?action=online&sid=$sid">".getnumonline()." </a>"; $noi2 = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_users WHERE perm>'0'")); echo "(";
$male=mysql_fetch_array(mysql_query("SELECT COUNT(DISTINCT a.userid) FROM ibwf_online a JOIN ibwf_users b ON a.userid = b.id WHERE b.sex='M'")); echo "M:$male[0]";
echo "/";
$female=mysql_fetch_array(mysql_query("SELECT COUNT(DISTINCT a.userid) FROM ibwf_online a JOIN ibwf_users b ON a.userid = b.id WHERE b.sex='F'")); echo "F:$female[0]"; echo ")"; echo " ";
Its ok 😉
echo "Online Stats"; echo " "; echo "Users: <a href="index.php?action=online&sid=$sid">".getnumonline()." </a>";
$timeout = 180; $timeon = time()-$timeout; $male = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE sex='M' AND lastact>'".$timeon."'")); echo " Male: <a href="index.php?action=maleol&sid=$sid">$male[0] </a> ";
$timeout = 180; $timeon = time()-$timeout; $female = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE sex='F' AND lastact>'".$timeon."'")); echo "Female: <a href="index.php?action=femol&sid=$sid">$female[0] </a> ";
echo " ";
In index.php
else if($action=="maleol") {
addonline(getuid_sid($sid),"Male online",""); echo "<card id="main" title="Male Online">";
//////ALL LISTS SCRIPT <<
if($page=="" || $page<=0)$page=1; $timeout = 180;$timeon = time()-$timeout; $noi = mysql_fetch_array(mysql_query("SELECT COUNT() FROM ibwf_users WHERE sex='M' AND lastact>'".$timeon."'")); $num_items = $noi[0]; //changable $items_per_page= 10; $num_pages = ceil($num_items/$items_per_page); if($page>$num_pages)$page= $num_pages; $limit_start = ($page-1)$items_per_page; if($limit_start<0)$limit_start=0; //changable sql $sql = " SELECT name, sex, id FROM ibwf_users WHERE sex='M' AND lastact>'".$timeon."' LIMIT $limit_start, $items_per_page"; echo "
"; $items = mysql_query($sql); echo mysql_error(); while ($item = mysql_fetch_array($items))
$lnk = "<a href=\"index.php?action=viewuser&who=$item[2]&sid=$sid\">$item[0]</a>"; echo ""; echo " "; echo"$lnk "; echo " "; echo " "; if($page>1) { $ppage = $page-1; echo "<a href="index.php?action=$action&page=$ppage&sid=$sid">«</a> "; } echo "$page/$num_pages"; if($page<$num_pages) { $npage = $page+1; echo " <a href="index.php?action=$action&page=$npage&sid=$sid">»</a>"; } echo " "; if($num_pages>2) { echo getjumper($action, $sid,"index"); } echo " "; ////// UNTILL HERE >>
echo " "; echo "<a href="index.php?action=main&sid=$sid"><img src="images/home.gif" alt="*"/>"; echo "Home</a>"; echo " "; echo "</card>"; }
else if($action=="femol") {
addonline(getuid_sid($sid),"Female online",""); echo "<card id="main" title="Female Online">";
//////ALL LISTS SCRIPT <<
if($page=="" || $page<=0)$page=1; $timeout = 180;$timeon = time()-$timeout; $noi = mysql_fetch_array(mysql_query("SELECT COUNT() FROM ibwf_users WHERE sex='F' AND lastact>'".$timeon."'")); $num_items = $noi[0]; //changable $items_per_page= 10; $num_pages = ceil($num_items/$items_per_page); if($page>$num_pages)$page= $num_pages; $limit_start = ($page-1)$items_per_page; if($limit_start<0)$limit_start=0; //changable sql $sql = " SELECT name, sex, id FROM ibwf_users WHERE sex='F' AND lastact>'".$timeon."' LIMIT $limit_start, $items_per_page"; echo "
"; $items = mysql_query($sql); echo mysql_error(); while ($item = mysql_fetch_array($items))
$lnk = "<a href=\"index.php?action=viewuser&who=$item[2]&sid=$sid\">$item[0]</a>"; echo ""; echo " "; echo"$lnk "; echo " "; echo " "; if($page>1) { $ppage = $page-1; echo "<a href="index.php?action=$action&page=$ppage&sid=$sid">«</a> "; } echo "$page/$num_pages"; if($page<$num_pages) { $npage = $page+1; echo " <a href="index.php?action=$action&page=$npage&sid=$sid">»</a>"; } echo " "; if($num_pages>2) { echo getjumper($action, $sid,"index"); } echo " "; ////// UNTILL HERE >>
echo " "; echo "<a href="index.php?action=main&sid=$sid"><img src="images/home.gif" alt="*"/>"; echo "Home</a>"; echo " "; echo "</card>"; }