Comments ID

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yddib
Forum Newbie
Posts: 4
Joined: Wed Sep 10, 2008 9:18 am

Comments ID

Post 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
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Comments ID

Post by yacahuma »

Can you please show the form you are using?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Comments ID

Post 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.
Post Reply