Jaynesh
1
Hello, I am trying to insert multiple rows in my table however it is only inserting one.
This is the query:
while( $i < $row = mysql_fetch_array($notification_query2))
{
mysql_query(“INSERT INTO notifIcations_data
(post_id
, user_id
, status
) VALUES (LAST_INSERT_ID(), '”.$row[‘user_id’].“', ‘1’)”);
}
I’m trying to insert a new row for each $row[‘user_id’] but it only inserts it for the first id.
Immerse
2
What’s this for?
$i < $row = mysql_fetch_array($notification_query2)
I think you want only $row = mysql_fetch_array($notification_query2)
Also, LAST_INSERT_ID() will continually change as you’re doing new inserts. Is that the intended functionality?
Cups
3
Are you aware of the INSERT … SELECT syntax?
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
http://dev.mysql.com/doc/refman/5.5/en/insert-select.html
Might be relevant, might not …