Problem writing a for loop for SQL
Posted: Thu Apr 09, 2009 12:02 pm
Hi there, im having problems trying to write this loop out
mysql_query("CREATE TABLE ".$Contents."(
PID INT (10) UNSIGNED not null AUTO_INCREMENT PRIMARY KEY,"
for ($x = 0; $x < ((count($rows)-2)/6); $x++)
{
$rows[3+($x*6)]
" VARCHAR(100),
}
)")
or die(mysql_error());
Basically, I got an array that has names for each column in the table and I want to iterate through it to end up with something like this.
mysql_query("CREATE TABLE constructor(
PID INT (10) UNSIGNED not null AUTO_INCREMENT PRIMARY KEY,
Row1 VARCHAR(100),
Row2 VARCHAR(100),
Row3 VARCHAR(100)
)")
or die(mysql_error());
Any ideas what im doing wrong?
mysql_query("CREATE TABLE ".$Contents."(
PID INT (10) UNSIGNED not null AUTO_INCREMENT PRIMARY KEY,"
for ($x = 0; $x < ((count($rows)-2)/6); $x++)
{
$rows[3+($x*6)]
" VARCHAR(100),
}
)")
or die(mysql_error());
Basically, I got an array that has names for each column in the table and I want to iterate through it to end up with something like this.
mysql_query("CREATE TABLE constructor(
PID INT (10) UNSIGNED not null AUTO_INCREMENT PRIMARY KEY,
Row1 VARCHAR(100),
Row2 VARCHAR(100),
Row3 VARCHAR(100)
)")
or die(mysql_error());
Any ideas what im doing wrong?