Jump to content
MakeWebGames

Events Help


The Spirit

Recommended Posts

Hey, I have a problem with my events page. It doesnt show the newest event, the event will then appear when you get another event.

Thanks if you can help. :)

 

<?php
include_once (DIRNAME(__FILE__). '/globals.php');
print "<br />";
if($ir['pagetutorials'] == 'ON')
{
print "
<table width=100% border='3' bordercolor='#BDBDBD' cellspacing='0' bgcolor='#FBFBE0' frame='border' rules='none'>
<tr>
<td width='75px'><img src='images/lightbulb.gif'><br /><font color='#999999'><i>[<a href='preferences.php'><font color='#999999'><i>Turn Off</i></font></a>]</i></font></center></td>
<td><br />
<center><h3 style='color:orange'>Events Tutorial</h3></center>
<p align='justify' style='margin-right:10px;margin-left:10px'><font color='#000'>
The events section is where all current news that has happened to you will be displayed. This could include events such as being attacked, being sent money or being rescued from jail. Again, events are displayed in chronological order, and can be easily deleted by using the Delete link. The events section also has a Delete all events, which clear the list of all your events.</font><br /><br /></td>
</tr></table><br />";
}
//Create Page Number's.
$limit = 10;
$page  = abs(@intval($_GET['page']));
$page  = !isset($page) ? $_GET['page'] : 1;
$by    = 'evTIME';
$order = 'DESC';
$rows  = mysql_query("SELECT `evID` FROM `events` WHERE `evUSER` = ".$ir['userid']);
$rows  = mysql_num_rows($rows);
$pages = ceil($rows/$limit);
if($rows % $limit == 0)
{
   $pages++;
}

if(isset($_POST['del_all']))
{
   mysql_query("DELETE FROM `events` WHERE `evUSER` = ".$ir['userid']) or die(mysql_error());
   echo 'All events have been deleted.';
}
if(isset($_GET['del']))
{
   $id = abs(@intval($_GET['del']));
   mysql_query("DELETE FROM `events` WHERE `evID` = ".$id." AND `evUSER` = ".$ir['userid']);
   echo 'Event deleted.';
}
if(isset($_POST['checkbox']))
{
   for($i = 0; $i < count($_POST['checkbox']); $i++)
   {
       mysql_query("DELETE FROM `events` WHERE `evID` IN(".$_POST['checkbox'][$i].") AND `evUSER` = ".$ir['userid']);
       $result = 1;
   }
   if($result == 1)
   {
       echo $i.' event(s) have been deleted.';
   }
   else
   {
       echo 'Error occured while trying to delete the event(s).';
   }
}

$pg = 'Page: ';
echo '<h2 align=center style=color:orange;font-family:arial>Player Events</h2>
<b>Note:</b> If you click on the check box and go to next page. The checkbox will be cleared. <br>
So delete the event\'s you want to delete before going to next page.<br><br>
<form action="'.$_SERVER['PHP_SELF'].'" method="post">'.$pg;
for($i = 1; $i <= $pages; $i++)
{
   $next = ($i * $limit);
   if ($i != 0) {
      echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$next.'">'.$i.'</a> - ';
      }
}

echo '<br><br>
<table width=95% cellpadding="5" align="center" style="border-style:solid;border-width:1px;border-color:#303030;"> <tr bgcolor="#606060" style="color:orange;font-family:Arial">
       <th>Time</th>
       <th>Event</th>
       <th>Links</th>
   </tr>';
  if ($page >= 10) { $page=$page-10; }
   $myEvents = mysql_query("SELECT `evTIME`, `evREAD`, `evTEXT`, `evID` FROM `events` WHERE `evUSER` = ".$ir['userid']." ORDER BY ".$by." ".$order." LIMIT ".$page.",".$limit);

   while($soc = mysql_fetch_assoc($myEvents))
   {
       $time = date('F j Y, g:i:s a', $soc['evTIME']);
       if(!$soc['evREAD'])
       {
           $new = '<br><b>New!</b>';
       }
       echo '
   <tr bgcolor="#404040">
       <td>'.$time.' '.isset($new).'</td>
       <td>'.$soc['evTEXT'].'</td>
       <td>
           <input type="checkbox" name="checkbox[]" value="'.$soc['evID'].'"> | ';
           if(isset($_GET['page']) )
           {
               echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'&del='.$soc['evID'].'">Delete</a>';
           }
           else
           {
               echo '<a href="'.$_SERVER['PHP_SELF'].'?del='.$soc['evID'].'">Delete</a>';
           }    echo '
       </td>
   </tr>
   <tr bgcolor="#404040">';
   }    echo '
   </tr>
</table>
<br>'.$pg;
for($i = 1; $i <= $pages; $i++)
{
   $next = ($i * $limit);
   if ($i != 0) {
      echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$next.'">'.$i.'</a> - ';
      }
}

echo '<br><br>
<input type="submit" value="Delete Selected Events">   |   <input name="del_all" id="del_all" type="submit" value="Delete All Events">
</form>';
if(isset($ir['new_events']) > 0)
{
   mysql_query("UPDATE `events` SET `evREAD` = 1 WHERE `evUSER` = ".$ir['userid']);
   mysql_query("UPDATE `users` SET `new_events` = 0 WHERE `userid` = ".$ir['userid']);
}
$h->endpage();
?>
Edited by The Spirit
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.

×
×
  • Create New...