...

View Full Version : How to do multiple querys in one?



Darren06
06-09-2004, 10:50 PM
Hi I have an install script that does multiple queries but when I tried to make it into one query variable it didnt work. Like this


<?php $query="CREATE TABLE categories (
id int(7) NOT NULL auto_increment,
category varchar(50) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=16 ;
INSERT INTO categories VALUES (1, 'Action');
INSERT INTO categories VALUES (2, 'Adventure');
INSERT INTO categories VALUES (3, 'Arcade');
INSERT INTO categories VALUES (4, 'Driving');
INSERT INTO categories VALUES (5, 'Multiplayer');
INSERT INTO categories VALUES (6, 'Puzzle');
INSERT INTO categories VALUES (7, 'Cards/Casino');
INSERT INTO categories VALUES (8, 'Sports');
INSERT INTO categories VALUES (9, 'Shooting');
INSERT INTO categories VALUES (10, 'Other');
CREATE TABLE games (
id int(7) NOT NULL auto_increment,
type varchar(6) NOT NULL default '',
name varchar(200) NOT NULL default '',
category varchar(200) NOT NULL default '',
filetype varchar(9) NOT NULL default '',
file text NOT NULL,
other text NOT NULL,
directions text NOT NULL,
link text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=60 ;";
?>

Other stuff is there but how can I make that all one mysql query?

missing-score
06-09-2004, 11:26 PM
quite simply, you cant.. mysql_query() can only do one query at a time.

You could put your queries into an array, and do them in a loop:



$sql[] = 'QUERY 1';
$sql[] = 'QUERY 2';
$sql[] = 'QUERY 3';

foreach($sql as $query){
mysql_query($sql);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum