Cod: Selectaţi tot
define("DB_HOST","localhost");
define("DB_LOGIN","gicu");
define("DB_PASSWORD","gicu");
define("DB_NAME","super");
mysql_connect(DB_HOST,DB_LOGIN,DB_PASSWORD)
or die ("Eroare de conectare!");
mysql_select_db(DB_NAME) or die (mysql_error());
$query= 'CREATE TABLE users (
id INT(8) NOT NULL AUTO_INCREMENT,
login VARCHAR(30) NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
) ';
$result = mysql_query($query);
$query='CREATE TABLE messages (
id INT(8) NOT NULL AUTO_INCREMENT,
message VARCHAR(30) NOT NULL,
message_from int(8) NOT NULL,
PRIMARY KEY (id)
) ';
$result = mysql_query($query);
$query = 'ALTER TABLE messages ADD FOREIGN KEY(message_from)
REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE ';
$result=mysql_query($query);
<?=$_SESSION["login"]?> a spus:<br>
<?=$user["message"]?>
ms