Jump to content
xisto Community
Sign in to follow this  
wappy

Code To Install Mysql Database Table?

Recommended Posts

Can anyone show me example code of how to install a database table instead of me having to upload an file with it in, so i can do it from a php page? Thanks in advance ;-)

Share this post


Link to post
Share on other sites

But i don't want to search google? I use this site and post my code snippets here, also i know for a fact someone here can help me with this.. What is the use in searching google when we can build a nice database of code and php help here? If i find the code before anyone replys with it i will post it here anyhow as it may be usefull to other users here.

Share this post


Link to post
Share on other sites

Hi
If You want Make install.php for your Script do this :
at first make config.php file with this codes :

<?php mysql_connect("localhost","Database Username","Database Password") or die(mysql_error()); mysql_select_db("Database Name") or die(mysql_error());?>
and then For Create tables in your database paste this code in install.php file :

include ("config.php"); mysql_query("CREATE TABLE news (id tinyint(4) NOT NULL auto_increment,text text NOT NULL,sub text NOT NULL,PRIMARY KEY (id)) TYPE=MyISAM; ");

With this code You create news tables in your Database
Tables news has 2 column ( Text and sub)
if you want make more column look at this query :
include ("config.php"); mysql_query("CREATE TABLE news (id tinyint(4) NOT NULL auto_increment,text text NOT NULL,sub text NOT NULL,time text NOT NULL,PRIMARY KEY (id)) TYPE=MyISAM; ");
at this query we add new column (time) to tabel
at end save install.php file and when you browse install.php in your browser your databse and tables are creat

Share this post


Link to post
Share on other sites

thanks alot, that is exactly what i was looking for :-) i can finish my script now, thanks again :-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.