Hi guys, i want to know if anybody here know how to integrate MySQL into website. If you know please make a tutorial here, thank you!
Printable View
Hi guys, i want to know if anybody here know how to integrate MySQL into website. If you know please make a tutorial here, thank you!
akulho you will be needing tables for your MSQL database set up..do tell me if you have login and user information already prepared in your database..if you have not i can cover it here that too..
1.so first create tables akulho if have not already created them
2.then fill in the database as required by you in the tables
3.use this code to now create table in your PHP which will be covering your MYSQL username and password..
<?
$user="username";
$password="password";
$database="database";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>
remember it is the standard table code am providing you where you can put your MYSQL username and password..
"VARCHAR"s are for your required contact info as you might be knowing
4.Next,you will need to issue the command to start a database connection:(with your local host)
mysql_connect(localhost,$username,$password);
5.before proceeding close MYSQL using this command
mysql_close();
6.now,select your database using this command(database containing ur username)
@mysql_select_db($database) or die( "Unable to select database");
(now i have included the die part coz its although not essential but serves to put an error control..you can leave it if you want)
7.now you should execute the command on your webserver..check it by this command
mysql_query($query);
8.ALL SET..now you can insert your contact info in the databse using this command..am using your username for example:
$query = "INSERT INTO contacts VALUES ('','akulho','ur last name','phone no.',' private number','youremailid.com','http://www.YOURWEBSITENAME.com')"
NOW YOU CAN ADD ANY OTHER THING YOU WANT..hope it helps :)
Thank a lot byyp, that's really helpful. I will try to setup the tabel using codes you has given here, and if something went wrong surely I know the one I would ask for help regarding this. Thanks again byyp.