I have the following query:
Code:
mysql_query("INSERT INTO messages (id, exped, uid, subiect, message, send_date) VALUES (0, '".$_SESSION['username']."', '".$fetch['user_id']."', '".$_POST['subiect']."', '".$_POST['mesaj']."', NOW())");
The query insert some data to mysql table called "messages".
I have an ID collumn in "messages table" with following option: id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
VALUES (0,.... 0 (the ID) auto increment at every row added to table.
When a new row added to table "messages", I need to get the ID of row and add to another table called "private"
I use this method:
Code:
mysql_query("INSERT INTO messages (id, exped, uid, subiect, message, send_date) VALUES (0, '".$_SESSION['username']."', '".$fetch['user_id']."', '".$_POST['subiect']."', '".$_POST['mesaj']."', NOW())");
$msg = mysql_query("SELECT id FROM messages WHERE message='".$_POST['mesaj']."'");
$msg_result = mysql_fetch_array($msg);
But is not good idea when $_POST['mesaj'] already exist in table.
Anyone help me a bit ? Any idea?