RevCMS Help

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
Ive almost fixed my chatlogs to work with the azure structure but I'm stuck on this last bit for searching for the username, because in the azure chatlogs structure, it enters the user id and I cant think how to make it pull the username in this line of code,
Code:
<?php
                      
$searchResults = null;
if (isset($_GET['timeSearch']))
{
        $_POST['searchQuery'] = $_GET['timeSearch'];
        $_POST['searchType'] = '4';
}
if (isset($_POST['searchQuery']))
{
        $query = filter($_POST['searchQuery']);
        $type = $_POST['searchType'];
      
        $q = "SELECT * FROM users_chatlogs WHERE ";
      
        switch ($type)
        {
                default:
                case '1':
              
                        $q .= "user_id = '" . $query . "'";
                        break;
                      
                case '2':
              
                        $q .= "message LIKE '%" . $query . "%'";
                        break;
                      
                case '3':
              
                        $q .= "room_id = '" . $query . "'";
                        break;
                      
                case '4':
              
                        $cutMin = intval($query) - 300;
                        $cutMax = intval($query) + 300;
                      
                        $q .= "timestamp >= " . $cutMin . " AND timestamp <= " . $cutMax;
        }
      
        $searchResults = mysql_query($q);
}
?>
any ideas? If more is needed I can post the whole chatlogs file I have for the HK?
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
yeah it works fine but im on about searching chatlogs on housekeeping, Ill post the code for the whole file I have for it for my housekeeping
PHP:
<?php
           
$searchResults = null;

if (isset($_GET['timeSearch']))
{
    $_POST['searchQuery'] = $_GET['timeSearch'];
    $_POST['searchType'] = '4';
}

if (isset($_POST['searchQuery']))
{
    $query = filter($_POST['searchQuery']);
    $type = $_POST['searchType'];
   
    $q = "SELECT * FROM users_chatlogs WHERE ";
   
    switch ($type)
    {
        default:
        case '1':
       
            $q .= "user_id = '" . $query . "'";
            break;
           
        case '2':
       
            $q .= "message LIKE '%" . $query . "%'";
            break;
           
        case '3':
       
            $q .= "room_id = '" . $query . "'";
            break;
           
        case '4':
       
            $cutMin = intval($query) - 300;
            $cutMax = intval($query) + 300;
           
            $q .= "timestamp >= " . $cutMin . " AND timestamp <= " . $cutMax;
    }
   
    $searchResults = mysql_query($q);
}


?>   
<?php

if (isset($searchResults))
{
    echo '<h2>Show
Results: - You have Searched for "<span style="font-size: 125%;">' . filter($_POST['searchQuery']) . '</span>"</h2>';
    echo '<br /><p><a href="chatlogs" class="btn btn-small btn-primary">Back to Search</a></p><br />
   
                           
<table class="table table-striped">
                                    <thead>
                                        <tr>
        <th>User</th>
        <th>Room</th>
        <th>Message</th>
        <th>Timestamp</th>
    </tr>
                                    </thead>
                                    <tbody>    ';
   
                                   
   
while ($result = mysql_fetch_assoc($searchResults))
    {
 
  $grabRoom2 = mysql_query("SELECT * FROM rooms_data WHERE id = '" . $result['room_id'] . "'");
   while ($room2 = mysql_fetch_assoc($grabRoom2))
   {
       $grabUser2 = mysql_query("SELECT * FROM users WHERE id = '" . $result['user_id'] . "'");
   while ($user2 = mysql_fetch_assoc($grabUser2))
   {
  
    echo '<tr">';
   
         // Username of sender
     echo '<td align="left" valign="top">' . $user2['username'] . '</td>';
    
     // Room ID
     echo '<td align="left" valign="top">' . $room2['caption'] . '</td>';
    
          // Message
     echo '<td align="left" valign="top">' . htmlspecialchars($result['message']) . '</td>';
    
          // Timestamp (UNIX Timestamp)
     echo '<td align="left" valign="top">' . date('m.d.y, g:i a', $result['timestamp']) . '</td>';
    
    echo '</tr>';
   
    echo '</tbody>
    </thead>
    </table>';
        }
   }
        }
                ?>
<?php } else { ?>
    <?php
   
    echo '<h2>Search Chatlogs</h2>
   
    <br />
   
    <form method="post">
   
    Search Type:&nbsp;
    <select name="searchType">
    <option value="1">By User</option>
    <option value="2">By message content</option>
    <option value="3">By Room (Single ID)</option>
    <option value="4">By timestamp (600 seconds range)</option>
    </select>
   
    <br /><br />
   
    Search:&nbsp;
    <input type="text" name="searchQuery">
   
    <br />
   
    <input type="submit" class="btn btn-small btn-primary" value="Search Records">
   
    </form>
   
   
    </br><h2>Recent Activity</h2>
                           
<table class="table table-striped">
                                    <thead>
                                        <tr>
        <th>User</th>
        <th>Room</th>
        <th>Message</th>
        <th>Timestamp</th>
    </tr>
                                    </thead>
                                    <tbody>    ';
                                   
   
$getWhisper = mysql_query("SELECT * FROM users_chatlogs ORDER BY id DESC LIMIT 30");
  while ($whisper = mysql_fetch_assoc($getWhisper))
  {
     
      $getWhisper2 = mysql_query("SELECT * FROM users WHERE id = '" . $whisper['user_id'] . "'");
  while ($whisper2 = mysql_fetch_assoc($getWhisper2))
  {
 
  $grabRoom = mysql_query("SELECT * FROM rooms_data WHERE id = '" . $whisper['room_id'] . "'");
   while ($room = mysql_fetch_assoc($grabRoom))
   {
  
    echo '<tr">';
   
         // Username of sender
     echo '<td align="left" valign="top">' . $whisper2['username'] . '</td>';
    
     // Room ID
     echo '<td align="left" valign="top">' . $room['caption'] . '</td>';
    
          // Message
     echo '<td align="left" valign="top">' . htmlspecialchars($whisper['message']) . '</td>';
    
          // Timestamp (UNIX Timestamp)
     echo '<td align="left" valign="top">' . date('m.d.y, g:i a', $whisper['timestamp']) . '</td>';
    
    echo '</tr>';
   
   }
  }
  }
    }
?>
 

Users who are viewing this thread

Top