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...
enjoy, n please assist someone!!!
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_page= 20;
$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>";
}
}
Comment