I have a table where i store the chat informations between 2 members (Member A and Member B). Now when Member A delete his messages i throw an sql request like this
$deleting = mysqli_query($connection, "DELETE FROM `mychattable` WHERE (`from`='$id_of_member_a' AND `to`='$id_of_member_b') OR (`from`='$id_of_member_b' AND `to`='$id_of_member_a') ") or die(mysqli_error($connection));
When i do that the problem is that it deletes the messages from both Member A and Member B's account.
I have also tried
$deleting = mysqli_query($connection, "DELETE FROM `mychattable` WHERE `from`='$id_of_member_b' AND `to`='$id_of_member_a' ") or die(mysqli_error($connection));
But when i do that it deletes the messages of Member A from the database so Member B no longer has access to it
How to delete the message received and sent by Member A from the chat without deleting it in member B's account ?
This is the structure of my table
CREATE TABLE IF NOT EXISTS `mychattable` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`from` int(10) unsigned NOT NULL,
`to` int(10) unsigned NOT NULL,
`message` text NOT NULL,
`sent` int(10) unsigned NOT NULL DEFAULT '0',
`read` tinyint(1) unsigned NOT NULL DEFAULT '0',
`direction` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `to` (`to`),
KEY `from` (`from`),
KEY `direction` (`direction`),
KEY `read` (`read`),
KEY `sent` (`sent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=29 ;
Thanks