View Full Version : mySQL with PHP?
Hitman
07-09-2006, 06:08 PM
Hey, I was looking on techtuts and when making a database you have to add the code table in myPHPadmin thing/mySQL thing, for shoutboxes or storing data (you could use flatfiles, but I'd prefer mySQL), how do they make them?
Could somebody explain, or point me in the right direction. Or even tell me a site.
Taken from a tutorial site:
CREATE TABLE `shoutbox` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`message` longtext NOT NULL,
`time` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
I don't get how it works, or how they make the code, as I said, can somebody explain?
+REP to any helpers! :)
:Blob
07-09-2006, 07:01 PM
Go to sql on cpanel, then to phpMyAdmin, select your database and click sql, paste the code in there
Hitman
07-09-2006, 07:37 PM
Did you miss-read? I want to know how to make them, not how to run them, I already know how to run them. I want to know, what do you do if you were, lets say, making a forum. What would you need if the forum had a profile, users, pm system and basic posting?
aspeas
07-09-2006, 07:46 PM
Did you miss-read? I want to know how to make them, not how to run them, I already know how to run them. I want to know, what do you do if you were, lets say, making a forum. What would you need if the forum had a profile, users, pm system and basic posting?
What blob said is how to make the tables in phpmyadmin.As far as I know that's what you want
Hitman
07-09-2006, 07:51 PM
Saying "Go to sql on cpanel, then to phpMyAdmin, select your database and click sql, paste the code in there" isn't helping me make anything? It's telling me to paste a code into phpmyadmin, which i dont want. I want how to make a MySQL code thing, like what each thing does.
Like what does "`id` int(11) NOT NULL auto_increment" do? What does each line mean?
Colin-Roberts
07-09-2006, 08:23 PM
id is like the number of the feild like say in my search pixel resources id is 1 int11 i have no idea what that means say with not null auto_increment is auto set next aviable number.
Edit: http://www.techtuts.com/?view=tutorials&act=tutorial&id=440
Motion
07-09-2006, 08:44 PM
auto_increment is to automatically create an id, like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.. Etc.
Mentor
08-09-2006, 12:37 AM
are you asking how to get php to exicute the Mysql code? or how to structure mysql code itself?
Hitman
08-09-2006, 07:16 AM
id is like the number of the feild like say in my search pixel resources id is 1 int11 i have no idea what that means say with not null auto_increment is auto set next aviable number.
Edit: http://www.techtuts.com/?view=tutorials&act=tutorial&id=440
Thanks, I'll check it out!
auto_increment is to automatically create an id, like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.. Etc.
Ok thanks Ryan.
are you asking how to get php to exicute the Mysql code? or how to structure mysql code itself?
I want to structure the code. I want to just learn what each part does, so when I come to making something that needs a database in mysql, i will be able to make one.
Mentor
08-09-2006, 06:39 PM
CREATE TABLE `shoutbox` (
Tells mysql you want to create a table, and that it should be called 'shoutbox'
`id` int(11) NOT NULL auto_increment,
Tells mysql in this table (its between the bracktes) you want to create a field. The first part tells it the fild is named ID the second part is the data type, in this instance, its int or intiger and the lengh of the field is 11. The net part says the value in the table cant be null. null being nothing, in this case the start value will automaticly be 0. Auto incriment means each row gets a unqie number
`name` text NOT NULL,
Same. except its a text field, and does auto incriment
`message` longtext NOT NULL,
Same again pretty much, except longtext
`time` text NOT NULL,
yet again pretty much the same
PRIMARY KEY (`id`)
Sets primary key, as id, basicly means its ordered by it by defult
) TYPE=MyISAM;
ends sql add table code, says table type is MyISAM, although in some of the newer mysql relices InnoDB is starting to take over "/
ps. Theres no php in that, its just the sql
Hitman
08-09-2006, 07:11 PM
CREATE TABLE `shoutbox` (
Tells mysql you want to create a table, and that it should be called 'shoutbox'
`id` int(11) NOT NULL auto_increment,
Tells mysql in this table (its between the bracktes) you want to create a field. The first part tells it the fild is named ID the second part is the data type, in this instance, its int or intiger and the lengh of the field is 11. The net part says the value in the table cant be null. null being nothing, in this case the start value will automaticly be 0. Auto incriment means each row gets a unqie number
`name` text NOT NULL,
Same. except its a text field, and does auto incriment
`message` longtext NOT NULL,
Same again pretty much, except longtext
`time` text NOT NULL,
yet again pretty much the same
PRIMARY KEY (`id`)
Sets primary key, as id, basicly means its ordered by it by defult
) TYPE=MyISAM;
ends sql add table code, says table type is MyISAM, although in some of the newer mysql relices InnoDB is starting to take over "/
ps. Theres no php in that, its just the sql
Just what I wanted thanks! +rep
So, what parts do you have to have in it, say like you were creating a forum? Also, how do you find out how long things are (like the 11 thing)?
Mentor
08-09-2006, 08:26 PM
depends on what you wana put in the field, its realy only useful for varchars most the time alot types will take an unspecifed lengh,
Plus forums usealy use a minimum of about 10 tables, u have users db, posts db, etc etc,
Hitman
09-09-2006, 05:54 AM
Hm, I think I get you. You've been the biggest help, cheers!
I will leave the thread open, for anybody else who wants to help. Or explain anything. ;)
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.