i want to create a table in the database using php (mysql_querry)
Table is having 'n' number of attributes. out of n, n-2 attribute names are available in the array.
I can't explain where i am getting the array but it looks like this- https://i.sstatic.net/tH98f.png
Here is the code for generating String to execute in mysql_querry.
$str="CREATE TABLE $register_name(id int NOT NULL AUTO_INCREMENT, date DATE, ";
$j=0;
while($j<$i)
{
$str=$str.$roll_no[$j]." int(100), ";
$j++;
}
$str=$str."PRIMARY KEY(id))";
require('blogic.php');
$obj = new blogic();
$createtable=$obj->create($str);
When i echo the $str, I get this:
CREATE TABLE $register_name(id int NOT NULL AUTO_INCREMENT, date DATE, 913310128 int(100), 0913310129 int(100), PRIMARY KEY(id))
However, it is giving error like this
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '913310128 int(100), 0913310129 int(100), PRIMARY KEY(id))' at line 1
I don't understand the problem. when i don't use roll_no array, it works fine.. Please let me know what is the problem in this.