Skip to content

Instantly share code, notes, and snippets.

@shivamMg
Created February 25, 2015 07:03
Show Gist options
  • Save shivamMg/07a548a12eaf9fc569ad to your computer and use it in GitHub Desktop.
Save shivamMg/07a548a12eaf9fc569ad to your computer and use it in GitHub Desktop.
<?php
$mysql_hostname = 'localhost';
$mysql_username = 'your_mysql_username';
$mysql_password = 'your_mysql_password';
$database = 'your_mysql_database';
$table = 'your_mysql_table' ;
$con = new mysqli($mysql_hostname, $mysql_username, $mysql_password, $database);
if ($con->connect_error) {
die($con->connect_error);
}
$i = 0;
while ($i <= 20000) {
/*
* Use $randomString for varchars and texts and $randomInteger for integers and
* real values.
*/
$randomString = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
$randomInteger = rand(1000, 5500);
$sql_query = "INSERT INTO $table (column1, column2) VALUES ('$randomString', '$randomInteger')";
if ($con->query($sql_query) === TRUE)
echo $i.' record added successfully.';
else
echo $i.' th record could not be added: '. $con->error;
$i = $i + 1;
}
$con->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment