magcr23 Posted June 24, 2015 Share Posted June 24, 2015 Hi guys, i have a private message system, but it was impossible to know when i had a reply, so i'm trying to do something like a notification systen, when a reply is sent i want to show in a page something like "reply from $FROM in $SUBJECT". so i did that: <?php $utilizador = $_SESSION["user"]; $resp = mysqli_query($con, "SELECT * FROM `messsages` WHERE `from` = '$utilizador' AND `read` = '0' "); $ln = mysqli_fetch_assoc($resp); //NOTIFICATION echo 'replyfrom: <b>' . $ln['from'] . ' </b>in <b>' . $ln['subject'] . '</b>'; ?> But if i do that it will show only the first one, how can i make it show them all? in my database i have: ID from to subject message date raiz (0=original message, 1=reply) read (0= user don't read, 1= user already read) Quote Link to comment https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/ Share on other sites More sharing options...
QuickOldCar Posted June 24, 2015 Share Posted June 24, 2015 (edited) Use a while loop while ($ln = mysqli_fetch_assoc($resp)) { echo 'replyfrom: <b>' . $ln['from'] . ' </b>in <b>' . $ln['subject'] . '</b><br />'; } Edited June 24, 2015 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/#findComment-1514789 Share on other sites More sharing options...
magcr23 Posted June 24, 2015 Author Share Posted June 24, 2015 Use a while loop while ($ln = mysqli_fetch_assoc($resp)) { echo 'replyfrom: <b>' . $ln['from'] . ' </b>in <b>' . $ln['subject'] . '</b><br />'; } I did that it was showing always the same data... I don't know what i did wrong xD But thx it worked Quote Link to comment https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/#findComment-1514790 Share on other sites More sharing options...
magcr23 Posted June 24, 2015 Author Share Posted June 24, 2015 (edited) . Edited June 24, 2015 by magcr23 Quote Link to comment https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/#findComment-1514792 Share on other sites More sharing options...
magcr23 Posted June 24, 2015 Author Share Posted June 24, 2015 Hi guys, i will need your help again, i created a form to the original message where: From:$user To:$a and my reply form is: From:$user To:$user_of_original_message When start the conversation it results in: message original: From: miguel To: admin Message: Hello reply1: From: admin To: miguel Message: Hi, how are you reply2: From: miguel To: miguel Message: IT'S NOT WORKING Since i'm using the $user_of_original_message it result that when i do the second reply i will sent a message to myself. How solve that? If no reply's-->to = $user_of_original_message if 1 or more reply exist-->to ? $user_of_reply_before how can i do that? there's the code if you want to see: http://justpaste.it/lyb2 (justpaste.it is an website to share text) Quote Link to comment https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/#findComment-1514802 Share on other sites More sharing options...
Solution Barand Posted June 24, 2015 Solution Share Posted June 24, 2015 Store message ids and which id you are replying to, if any message original: MessageID = 1 From: miguel To: admin Message: Hello ReplyToID = null reply1: MessageID = 2 From: admin To: miguel Message: Hi, how are you ReplyToID = 1 reply2: MessageID = 3 From: miguel To: miguel Message: IT'S NOT WORKING ReplyToID = 1 Quote Link to comment https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/#findComment-1514838 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.