group inbox messages by day

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    group inbox messages by day

    ok, i am coding script, message table similat to lava if from user, touser, date, etc... i added year month n day trying to get following code to work, should list messages like skype ie: each day in separate div... but i got a bug somewhere, was working yesterday, now sticking on last day n i can't figure out what i done, n its doing my head in now lol... n thought i'd post here since I'm guessing others might like code... Really simple, but got one bug...

    PHP Code:
    echo "<div id='convo_box'>";
    if(
    $page=="" || $page<=0)$page=1;
    $noi mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM bl0gger_messages WHERE (touser='$username' AND fromuser='$whofrom') OR (touser='$whofrom' AND fromuser='$username')"));

        
    $num_items $noi[0]; //changable
        
    $items_per_page20;
        
    $num_pages ceil($num_items/$items_per_page);
        if((
    $page>$num_pages)&&$page!=1)$page$num_pages;
        
    $limit_start = ($page-1)*$items_per_page;

        
    //changable sql

    echo "<div style='background:black; color:white;' align='center'>$username - $whofrom</div><br/>";
              
    $sql "SELECT DISTINCT(day) FROM bl0gger_messages WHERE (touser='$username' AND fromuser='$whofrom') OR (touser='$whofrom' AND fromuser='$username') ORDER BY id DESC LIMIT 20";

        
    $items mysql_query($sql);
        if(
    mysql_num_rows($items)>0)
        {

        while (
    $item mysql_fetch_array($items))
        {
        echo 
    "<div style='border:1px black ridge;' align='left'>$item[0]<br/>";
        
    /////////////
        
    $sql "SELECT id, touser, fromuser, msgtext, msgtime, seen FROM bl0gger_messages WHERE (touser='$username' AND fromuser='$whofrom'  AND day='$item[0]') OR (touser='$whofrom' AND fromuser='$username'  AND day='$item[0]') ORDER BY id DESC";

        
    /////////////
            
    $items mysql_query($sql);
        
    $x 1;
        if (
    $x=="1"||$x=="3"||$x=="5"||$x=="7"||$x=="9")
        {
         
    $nickcol "blue";
        }
        else
        {
         
    $nickcol "red";
        }
        if(
    mysql_num_rows($items)>0)
        {
        while (
    $item mysql_fetch_array($items))
        {
          
    $text getbbcode($item[3]);
          echo 
    "<div align='left'>";
          echo 
    "<font color='$nickcol'>$item[2]</font> -> $text<br/>";
          echo 
    "<small>Sent: ".date('l jS \of F Y h:i:s A'$item[4])."</small>";

          echo 
    "</div>";
        }
        }
        echo 
    "</div>";
        }

     } 
    enjoy, n please assist someone!!!
    C3 Themes: http://c3themes.wen.ru/index.html
    Find Files: http://mystarter.tk/?goto=X-search

    #2
    dont have xactly that but i sorted shoutbox history by days heres what i use so should be useful in creating your code

    PHP Code:
    page $_request['page']?$_request['page']:1;
    $time strtotime("-".($page-1)." day");
    $day_date date("Y-m-d",$time);
    $query mysql_query("SELECT * FROM extras WHERE type = 'S' AND date = '$day_date' ORDER BY time DESC"); 
    that will sort them by pages under day so page 1 will be current day and page 2 yesterday etc

    to get day names use this

    PHP Code:
    date("D",strtotime('-1 day')); \\yesterday
    date
    ("D",strtotime('-2 day')); \\day before yesterday etc 

    Comment

    Working...
    X