0

I couldn't figure out this problem where I have multiple records from other tables, trying to transfer to another table.

So every time they press insert button, these records will be transferred but I do not know how to make them have the same reference id (Just a column for me to set all these records with the same id).

If they press again the insert button, the reference id will be different.

$input_comment = $_POST["comments"];
$sql3 = "INSERT INTO QuotationService 
             (referid, username, date, shiptype, city, country, poe, volume, volume2, service, included, price, comment) 
             SELECT username, date, shiptype, city, country, poe, volume, volume2, service, included, price, '$input_comment' 
             FROM ServiceHolds
             WHERE username='$login_session' AND id=(SELECT MAX(id) FROM ServiceHolds)";
mysqli_query($conn, $sql3);

What should I do for my referid so that my conditions for what I said above will work?

This is a $_SERVER request method.

Mickaël Leger
  • 3,426
  • 2
  • 17
  • 36
DJ CruzC
  • 19
  • 2
  • Please make your question clear, I really cannot get what your're expecting. – LF00 Oct 31 '19 at 08:11
  • It will transfer only one record at a time and it will be always the last one of that user if the `ID` column on `ServiceHolds` table is `autoincrement`. and if the last record `username` is not match with the last record then nothing will be copied in `QuotationService` table – Dhaval Purohit Oct 31 '19 at 09:11
  • Well you can just add a random string in php and use it ? – Mickaël Leger Oct 31 '19 at 10:11
  • Your code is vulnerable to SQL injection. You should use prepared statements. – Dharman Oct 31 '19 at 11:01

0 Answers0