...PHP?
Or do I have to upload SQL files or whatever. It seems it's possible to create tables on the database. Doesn't phpBB do it?
If it IS possible, would you mind showing me where I might learn how to do it?
And if you could, might you direct me to some place that teaches you how to input information into a table using PHP?
Is it possible to create tables on a MySQL database using
Moderator: General Moderators
yes you can use php to create tables.
that should work, if anyone sees a mistake in it then plz fix it.
go to http://www.hotscripts.com/Detailed/4315.html, thay have some tuts for php, try that tut.
hope that helps.
Code: Select all
<?php
$database = mysql_connect('localhost', 'username','password');
mysql_create_db('db_name', $database);
mysql_select_db('db_name);
$query = "CREATE TABLE new_table (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, new_col VARCHAR(25))";
$result = mysql_query($query);
$axeit = mysql_drop_db('db_name');
?>that should work, if anyone sees a mistake in it then plz fix it.
go to http://www.hotscripts.com/Detailed/4315.html, thay have some tuts for php, try that tut.
hope that helps.
Thanks amigo 
It worked. Now I just have to figure what all the stuff means...
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
means nothing to me...
*edit*
Also, if I want to create a signup kinda form and save all the information on this database, how do I make sure every person who input his/her information input it into a new field.
Know what I mean? I don't want every input to overwrite other input. I want each to have it's own id if that's the word.
It worked. Now I just have to figure what all the stuff means...
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
means nothing to me...
*edit*
Also, if I want to create a signup kinda form and save all the information on this database, how do I make sure every person who input his/her information input it into a new field.
Know what I mean? I don't want every input to overwrite other input. I want each to have it's own id if that's the word.
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
here, lemme break that down for ya
SQL fragment: id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
creates a field named 'id' of type INT. it is set so as not to allow NULL values. every time you insert a new row this field will generate a unique number in sequence (1,2,3,4,5,6,7,8) with each subsequent insert. it isthen made the primary indexing key (items in this field must be unique and will automaticlly be indexed).
hope that clarifys it for you.
SQL fragment: id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
creates a field named 'id' of type INT. it is set so as not to allow NULL values. every time you insert a new row this field will generate a unique number in sequence (1,2,3,4,5,6,7,8) with each subsequent insert. it isthen made the primary indexing key (items in this field must be unique and will automaticlly be indexed).
hope that clarifys it for you.
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
You can do too things. First is to specify what fileds to insert into:
The second is to include the value but with a random or null value:
Hope that helps.
Cheers Sam
Code: Select all
INSERT INTO table ('name','age','height') VALUES ('Sam McKone','20','6 feet 5 inches');Code: Select all
INSERT INTO table VALUES ('0','Sam McKone','20','6 feet 5 inches');Cheers Sam
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Since your id field is auto-incrementing you can use the following SQL statement:
Because you set the id field to NULL, MySQL will just add 1 to the previous id value in the table to get the value for the new record (ie. auto-increment the field).
Mac
Code: Select all
INSERT INTO table VALUES (NULL,'Sam McKone','20','6 feet 5 inches');Mac