Jump to content

[SOLVED] Help with Select & Inserts


yddib

Recommended Posts

$comment=$_POST['comment'];
$linda='1';


mysql_query("SELECT f_name, l_name FROM gradinfo WHERE u_id = '$id'");
mysql_query("INSERT INTO comments (from_u_id,comment,u_id,f_name,l_name) VALUES ('$id', '$comment','$linda','f_name','l_name')");

 

We know this inserts f_name & l_name instead of the name linked with $id.

How do I drag the 2 selected fields to be inserted in another table?

Link to comment
https://forums.phpfreaks.com/topic/123922-solved-help-with-select-amp-inserts/
Share on other sites

$result = mysql_query("SELECT f_name, l_name FROM gradinfo WHERE u_id = '$id'");
$row = mysql_fetch_array($result);
mysql_query("INSERT INTO comments (from_u_id,comment,u_id,f_name,l_name) VALUES ('$id', '$comment','$linda','{row['f_name']}','{$row['l_name']}')");

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.