Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple PHP and mySQL - create a table...

Status
Not open for further replies.

rjonesX

Technical User
Jun 18, 2001
56
US
Lets say I am using the following to connect to a mySQL database of mine...

$dbh=mysql_connect ("localhost", "nichols_general", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("nichols_news");


I want to create the table with the following columns...

title : description : day : month : year : content


how do I create such a table with PHP?
 
//create "example" table
$figures = "CREATE TABLE example (
example_title VARCHAR(50) NOT NULL,
example_description VARCHAR(200) NOT NULL,
example_day VARCHAR(7) NOT NULL,
example_month int(6) NOT NULL,
example_year int(4) NOT NULL,
example_content VARCHAR(200) NOT NULL,
PRIMARY KEY (for you to decide)
)";

$results = mysql_query($figures)
or die (mysql_error());

echo "Example Database successfully created!";

This is only to get you started, the dates should be addressed in the appropriate manner.

O
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top