Skip to content

Instantly share code, notes, and snippets.

@mahdiyazdani
Created July 19, 2019 06:33
Show Gist options
  • Save mahdiyazdani/e324e4a518ad1d896476002f9d67aa45 to your computer and use it in GitHub Desktop.
Save mahdiyazdani/e324e4a518ad1d896476002f9d67aa45 to your computer and use it in GitHub Desktop.
Insert array to mysql
<?php
$mysqli = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ) or die( 'Could not connect' );
// Check connection
if ( mysqli_connect_errno() ) {
printf( "Connect failed: %s\n", mysqli_connect_error() );
exit();
}
$values = array(
'XXX',
'XXX2',
'XXX3'
);
foreach( $values as $value ) {
$mysqli->query( "INSERT INTO `TABLE` (`COLUMN`) VALUES ('$value')" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment