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());

 

Link to comment
Share on other sites

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)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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