Jump to content

Show data from data base


Go to solution Solved by Barand,

Recommended Posts

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)

Link to comment
https://forums.phpfreaks.com/topic/296997-show-data-from-data-base/
Share on other sites

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)

  • Solution

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.