Jump to content

Any proper methods for multiple INSERT command?


genzedu777

Recommended Posts

Hi guys,

 

I am just wondering if there is a proper method to streamline my codes, whenever I perform multiple INSERTs into tables? Probably like INNER JOIN method etc? Thanks

 

 

$query = "INSERT INTO practice_user (name, email, password, dob, category, comments) VALUES ('$name', '$email', '$password', '$dob', '$category', '$comments')";

 

  $result = mysqli_query($dbc, $query)

    or die(mysql_error());

 

$query2 = "INSERT INTO location (name) VALUES ('$location')";

 

  $result = mysqli_query($dbc, $query2)

    or die(mysql_error());

 

It is not possible with two different tables. for single table you can do that

 

$query = "INSERT INTO practice_user (name, email, password, dob, category, comments) VALUES ('$name', '$email', '$password', '$dob', '$category', '$comments'), ('$name', '$email', '$password', '$dob', '$category', '$comments'), ('$name', '$email', '$password', '$dob', '$category', '$comments'), ('$name', '$email', '$password', '$dob', '$category', '$comments'), ('$name', '$email', '$password', '$dob', '$category', '$comments')";

 

  $result = mysqli_query($dbc, $query)

 

 

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.