Subject Re: creating unique key : usingprimair key and foreign key
From Ronnie MacGregor <No_Sp@m.Thanks>
Date Sun, 7 Feb 2021 11:06:42 -0000
Newsgroups dbase.getting-started

In article <zqtJN$L$WHA.1876@ip-AC1E04A7>, dbase@nospam.goldenstag.net
says...

> I've been fine
> with the non-object version, so the -> syntax isn't in my code.)

I forgot to say that there is an assumption here that the table has an
auto generated AUTO_INCREMENT field. Also, a result of zero is returned
if the INSERT failed or there is no AUTO_INCREMENT field.

Procedural version :

<?php
  
   $con = mysqli_connect("localhost","username","password","db");
  
   mysqli_query($con, "INSERT INTO People (
      FirstName,
      LastName,
      Age
      )
      VALUES (
     'Ken',
     'Mayer',
     1000
     )");

   echo "New Row ID = " . mysqli_insert_id($con);

   mysqli_close($con);

?>