yddib Posted September 12, 2008 Share Posted September 12, 2008 $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 More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 $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']}')"); Link to comment https://forums.phpfreaks.com/topic/123922-solved-help-with-select-amp-inserts/#findComment-639703 Share on other sites More sharing options...
yddib Posted September 12, 2008 Author Share Posted September 12, 2008 You're a star!! Thanks!! Link to comment https://forums.phpfreaks.com/topic/123922-solved-help-with-select-amp-inserts/#findComment-639707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.