I have PHP program which insert 4 row once when run. I want to keep first log_ID(auto incremental)
same parent_ID
for every 4 row.
like Below:
on 1st run program:
log_ID name parent_ID
====== ===== ==========
1 abc 1
2 def 1
3 ghi 1
4 jkl 1
on 2nd run program:
log_ID name parent_ID
====== ===== ==========
1 abc 1
2 def 1
3 ghi 1
4 jkl 1
5 xyz 5
6 abc 5
7 stu 5
8 jkl 5
This is a brief idea about how you can handle the problem..
<?php
$query1 = "YOUR FIRST INSERT QUERY";
mysql_query($query1);
$last_log_id = mysql_insert_id(); //here you will get the log_id generated for the previous query (auto incremental)
//set the above last_log_id as parent_id of the previous row. ie., update query for row with `log_id` $last_log_id
$update_query = "YOUR UPDATE QUERY FOR FIRST ROW";
$query2 = "YOUR SECOND INSERT QUERY WITH PARENT_ID AS $last_log_id";
mysql_query($query2);
$query3 = "YOUR THIRD INSERT QUERY WITH PARENT_ID AS $last_log_id";
mysql_query($query3);
$query4 = "YOUR FOURTH INSERT QUERY WITH PARENT_ID AS $last_log_id";
mysql_query($query4);
?>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments