Reputation: 799
I have this code.
elseif ($numerodeprocesos == 4) {
$upd2= "INSERT INTO juan (ciudadh)
VALUES ('$ciudadh')";
$upd3= "INSERT INTO juan (ciudadh)
VALUES ('$ciudadh')";
$upd4= "INSERT INTO juan (ciudadh)
VALUES ('$ciudadh')";
$upd5= "INSERT INTO juan (ciudadh)
VALUES ('$ciudadh')";
$upd6= "INSERT INTO juan (ciudadh)
VALUES ('$ciudadh')";
mysql_query($upd2)or die( mysql_error() );
mysql_query($upd3)or die( mysql_error() );
mysql_query($upd4)or die( mysql_error() );
mysql_query($upd5)or die( mysql_error() );
mysql_query($upd6)or die( mysql_error() );
}
But, what is the most simple way do to that? I mean it is possyble to do it in one single mysql_query?
Thanks in advance for your help
Upvotes: 0
Views: 118
Reputation: 173572
This would be a single insert statement that inserts multiple rows:
INSERT INTO juan (ciudadh)
VALUES ('$ciudadh'), ('$ciudadh'), ('$ciudadh'), ('$ciudadh');
See also: INSERT Syntax
Upvotes: 4