I have to insert single set of data multiple times , say n rows.
INSERT INTO MyTable VALUES ("John", 123, "US");
Can I insert all n rows in a single SQL statement?
here n
is dynamic value n is user input , how to make insert query n times , any idea.
$sql = "INSERT INTO `mytable` VALUES(`field1`,`field2`,`date`) VALUES ";
$count = 5;
for($i=0;$i<$coutn;$i++)
{
if($type=="daily")
{
$st=date('Y-m-d H:i:s', strtotime('+1 day', strtotime('$st')));
}
else if($type=="monthly")
{
$st=date('Y-m-d H:i:s', strtotime('+30 day', strtotime('$st')));
}
$sql .= " ('john','123','$st' )";
}
is this correct way..