Jump to content
MakeWebGames

Display amount of users in jail/hospital in mainmenu


bloodless2010
 Share

Recommended Posts

Hey again,

how do I display the amount of users in jail/hospital in V1?

I'm using this jail for V1: http://makewebgames.io/showthread.php/31352-mccode-v1-Mccodes-V1-Jail

My Mainmenu:

<?php
/*
MCCodes FREE
mainmenu.php Rev 1.1.0
Copyright (C) 2005-2012 Dabomstew

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

if (strpos($_SERVER['PHP_SELF'], "mainmenu.php") !== false)
{
   exit;
}
global $c, $ir;
if (!$ir['hospital'])
{
   print
           "<a href='index.php'>Home</a><br />
<a href='inventory.php'>Items</a><br />
<a href='explore.php'>Explore</a><br />
<a href='events.php'>";
   $d =
           mysql_query(
                   "SELECT COUNT(*) as cnt FROM events WHERE evUSER={$ir['userid']} AND evREAD=0",
                   $c) or die(mysql_error());
   $r = mysql_fetch_array($d);
   if ($r['cnt'] > 0)
   {
       print "<b>Events ({$r['cnt']})</b>";
   }
   else
   {
       print "Events (0)";
   }
   print "</a><br />
<a href='mailbox.php'>";
   $d2 =
           mysql_query(
                   "SELECT COUNT(*) as cnt FROM mail WHERE mail_to={$ir['userid']} AND mail_read=0",
                   $c) or die(mysql_error());
   $r = mysql_fetch_array($d2);
   if ($r['cnt'] > 0)
   {
       print "<b>Mail ({$r['cnt']})</b>";
   }
   else
   {
       print "Mail (0)";
   }
   print
           "</a><br />
<a href='gym.php'>Gym</a><br />
<a href='criminal.php'>Crimes</a><br />
<a href='jail.php'>Jail ()</a><br />
<a href='hospital.php'>Hospital ()</a><br />
<a href='education.php'>Local School</a><br />
<a href='monopaper.php'>Announcements</a><br />
<a href='search.php'>Search</a><br />
<a href='advsearch.php'>Advanced Search</a><br />";
   if ($ir['user_level'] > 1)
   {
       print "<hr />
<b>Staff Only</b><br />\n";
       if ($ir['user_level'] < 6 and $ir['user_level'] != 4)
       {
           print "<a href='new_staff.php'>Staff Panel</a><br />\n";
       }
   }
   if ($ir['user_level'] > 1)
   {
       print "<hr /><b>Staff Online:</b><br />";
       $q =
               mysql_query(
                       "SELECT * FROM users WHERE laston > " . (time() - 900)
                               . " AND user_level>1 ORDER BY userid ASC", $c);
       while ($r = mysql_fetch_array($q))
       {
           $la = time() - $r['laston'];
           $unit = "secs";
           if ($la >= 60)
           {
               $la = (int) ($la / 60);
               $unit = "mins";
           }
           if ($la >= 60)
           {
               $la = (int) ($la / 60);
               $unit = "hours";
               if ($la >= 24)
               {
                   $la = (int) ($la / 24);
                   $unit = "days";
               }
           }
           print
                   "<a href='viewuser.php?u={$r['userid']}'><font color={$r['username_color']}>{$r['username']}</font></a> ($la $unit)<br />";
       }
   }
   if ($ir['donatordays'])
   {
       print
               "<hr />
<b>Donators Only</b><br />
<a href='friendslist.php'>Friends List</a><br />
<a href='blacklist.php'>Black List</a>";
   }
   print
           "<hr />
<a href='preferences.php'>Preferences</a><br />
<a href='preport.php'>Player Report</a><br />
<a href='helptutorial.php'>Help Tutorial</a><br />
<a href='gamerules.php'>Game Rules</a><br />
<a href='viewuser.php?u={$ir['userid']}'>My Profile</a><br />
<a href='logout.php'>Logout</a><br /><br />
Time is now<br />
           ";
   echo date('F j, Y') . "<br />" . date('g:i:s a');
}
else
{
   print
           "<a href='index.php'>Home</a><br />
<a href='inventory.php'>Items</a><br />
<a href='events.php'>";
   $d =
           mysql_query(
                   "SELECT COUNT(*) as cnt FROM events WHERE evUSER={$ir['userid']} AND evREAD=0",
                   $c) or die(mysql_error());
   $r = mysql_fetch_array($d);
   if ($r['cnt'] > 0)
   {
       print "<b>Events ({$r['cnt']})</b>";
   }
   else
   {
       print "Events (0)";
   }
   print "</a><br />
<a href='mailbox.php'>";
   $d2 =
           mysql_query(
                   "SELECT COUNT(*) as cnt FROM mail WHERE mail_to={$ir['userid']} AND mail_read=0",
                   $c) or die(mysql_error());
   $r = mysql_fetch_array($d2);
   if ($r['cnt'] > 0)
   {
       print "<b>Mail ({$r['cnt']})</b>";
   }
   else
   {
       print "Mail (0)";
   }
   print
           "</a><br />
<a href='monopaper.php'>Announcements</a><br />
<a href='search.php'>Search</a><br />";
   if ($ir['user_level'] > 1)
   {
       print "<hr />
<b>Staff Only</b><br />";
       if ($ir['user_level'] < 6 and $ir['user_level'] != 4)
       {
           print "<a href='new_staff.php'>Staff Panel</a><br />\n";
       }
   }
   if ($ir['user_level'] > 1)
   {
       print "<hr /><b>Staff Online:</b><br />";
       $q =
               mysql_query(
                       "SELECT * FROM users WHERE laston>(" . time()
                               . "-15*60) AND user_level>1 ORDER BY userid ASC",
                       $c);
       while ($r = mysql_fetch_array($q))
       {
           $la = time() - $r['laston'];
           $unit = "secs";
           if ($la >= 60)
           {
               $la = (int) ($la / 60);
               $unit = "mins";
           }
           if ($la >= 60)
           {
               $la = (int) ($la / 60);
               $unit = "hours";
               if ($la >= 24)
               {
                   $la = (int) ($la / 24);
                   $unit = "days";
               }
           }
           print
                   "<a href='viewuser.php?u={$r['userid']}'><font color={$r['username_color']}>{$r['username']}</font></a> ($la $unit)<br />";
       }
   }
   if ($ir['donatordays'])
   {
       print
               "<hr />
<b>Donators Only</b><br />
<a href='friendslist.php'>Friends List</a><br />
<a href='blacklist.php'>Black List</a>";
   }
   print
           "<hr />
<a href='preferences.php'>Preferences</a><br />
<a href='preport.php'>Player Report</a><br />
<a href='helptutorial.php'>Help Tutorial</a><br />
<a href='gamerules.php'>Game Rules</a><br />
<a href='viewuser.php?u={$ir['userid']}'>My Profile</a><br />
<a href='logout.php'>Logout</a><br /><br />
Time is now<br />
           ";
   echo date('F j, Y') . "<br />" . date('g:i:s a');
}

 

ATM I'm just using (), but I want it to display like (5) if 5 people are in jail/hospital ect. Thank you!

Link to comment
Share on other sites

I don't understand how you mean, because they look into a certain table, and I'm not very good at MySQL,

I know the PHP I think, but not how to use MySQL,

I just want it to count how many users have more then 0 jail/hospital time.

Edit; Nevermind! I worked it out, thanks for giving me the idea! :D

Edited by bloodless2010
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...