Page 1 of 1

Comments ID

Posted: Fri Sep 12, 2008 7:00 am
by yddib

Code: Select all

 
<?php 
session_start();
$id = $_SESSION['id'];
?>
 
<?php
$comment=$_POST['comment'];
 
mysql_query("INSERT INTO comments (from_u_id, comment) VALUES ('$id', '$comment')");
 
echo "Comment added successfully.";
This code works to drag the comment and the senders id to the database but I don't know how to get the id of the person i'm sending it to!

I will try and break down exactly what we're trying to do. It's all a bit new to us!!


People log into the system and use sessions with their user ID
When posting comments we want to use their user id (to and from) so that the correct comment is displayed on their page
We also want their names to show up so they know who it is from

Re: Comments ID

Posted: Fri Sep 12, 2008 8:02 am
by yacahuma
Can you please show the form you are using?

Re: Comments ID

Posted: Fri Sep 12, 2008 8:08 am
by jayshields
Have you got a users table? You'll probably want some sort of join between the two tables on the user ID so that you can fetch the username. I guess you'll want 2 user ID's in the comments table, a from ID and a to ID.