Lone_Ranger Posted December 10, 2013 Share Posted December 10, 2013 Im trying to create a message system my database field has userid, receiveid, username, receivename, message, date, read userid is the id of the person sending the message receiveid is the id of the person receiving the message username is the name of the senders name recievename is the name of the person receiving the message message is the message date is the date sent read is always set as no but will be set as yes when someone access the message. this is my code so far $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $pages = implode(mysql_fetch_assoc(mysql_query("SELECT COUNT(id) FROM imessages"))); $pages = ceil($pages / 15); $querystring = ""; foreach ($_GET as $key => $value) { if ($key != "page") $querystring .= "$key=$value&"; } echo "Pages: "; for ($i = 1; $i <= $pages; $i++) { echo "<a " . ($i == $page ? "class=\"selected\" " : ""); echo "href=\"?{$querystring}page=$i"; echo "\">$i</a> "; echo "<p><b>Inbox</b> | Recieved Messages :: <a href=http://www.sentuamessage.com/inbox.php?action=sentmessages>Sent Messages</a></p>"; } $result = mysql_query("SELECT * FROM imessages where recieveid='$row[id]' order by date ASC LIMIT " . (($page - 1) * 15) . ", 15"); while($news = mysql_fetch_array($result)) { $position=500; $message="$news[message]"; $post = substr($message, 0, $position); echo "<table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <td> <table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <td> <table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <td> <table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <td width=29> </td> <td width=27><img src=http://www.sentuamessage.com/commentsavatar.jpg></img></td> <td width=27> </td> <td>"; echo utf8_encode($post); echo "..."; echo "</td> </tr> </table> </td> <td width=10> </td> </tr> <tr> <td><p align=right><font size=2><b><a href=http://www.sentuamessage.com/profile.php?who=$news[recieveid]>$news[recievename]</a></b></font></p></td> <td width=10> </td> </tr> </table> </td> <td width=10 bgcolor=#008000> </td> <td width=31> </td> </tr> </table> </td> </tr> <tr> <td> </td> </tr> </table>"; } echo "Pages: "; for ($i = 1; $i <= $pages; $i++) { echo "<a " . ($i == $page ? "class=\"selected\" " : ""); echo "href=\"?{$querystring}page=$i"; echo "\">$i</a> "; } I want this to be my inbox, it would work like facebook, where it shows the latest message from the person in the conversation, so if I had 5 messages off 1 user it only shows the latest one and not the other 4. When you access the most recent message then you can see the history of your chat with that user. How can I do this, what would be the best possible way? Quote Link to comment https://forums.phpfreaks.com/topic/284685-messaging-system/ Share on other sites More sharing options...
gristoi Posted December 10, 2013 Share Posted December 10, 2013 ajax Quote Link to comment https://forums.phpfreaks.com/topic/284685-messaging-system/#findComment-1461975 Share on other sites More sharing options...
Lone_Ranger Posted December 11, 2013 Author Share Posted December 11, 2013 I figured out a work around to my own answer without using AJAX. Only problem I am having now is if I'm doing a MYSQL query and have where item=item && item2=item2 I keep getting a Boolean error when uploaded. Quite annoying why would this be? in this case for an example a count MySQL query where a row = user id && read = no it would come back with a boolean Quote Link to comment https://forums.phpfreaks.com/topic/284685-messaging-system/#findComment-1462020 Share on other sites More sharing options...
Solution Lone_Ranger Posted December 11, 2013 Author Solution Share Posted December 11, 2013 (edited) Don't worry figured it wasn't my coding was due to a server problem seems it didn't like the read syntax Edited December 11, 2013 by Lone_Ranger Quote Link to comment https://forums.phpfreaks.com/topic/284685-messaging-system/#findComment-1462049 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.