Code: Select all
$query = "CREATE TABLE members (
member_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 50 ) NOT NULL UNIQUE,
firstname VARCHAR( 50 ) NOT NULL ,
lastname VARCHAR( 50 ) NOT NULL ,
title VARCHAR(10),
password VARCHAR( 50 ) NOT NULL ,
primary_email VARCHAR(100),
secondary_email VARCHAR(100),
register_date DATE,
ip VARCHAR( 50 ) NOT NULL ,
UNIQUE (username)
)";
Code: Select all
$query = "CREATE TABLE blogs (
blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
member_id INT UNSIGNED,
like_id INT UNSIGNED,
title VARCHAR( 500 ) NOT NULL,
entry VARCHAR( 2000 ) NOT NULL ,
blog_date DATE
)";
Code: Select all
$query = "INSERT INTO blogs ( member_id, title, entry, blog_date) VALUES ( 'SELECT member_id FROM members', '{$_POST['title']}', '{$_POST['entry']}', NOW())";
Code: Select all
$query= 'SELECT * FROM blogs';
if($r = mysql_query ($query)) {//Run the query.
//Retrieve and print every record.
while ($row = mysql_fetch_array ($r)) {
print " {$row['title']}" ;
print " {$row['entry']}" ;
print " {$row['blog_date']}" ;
print " {$row['member_id']}" ;
}
} else {//Query didn't run.
die (' Could not retrieve the data becasue: .mysql_error().
');
}//End of query IF.
mysql_close(); //Close the database connection.
[text]Any help is appreciated.[/text]