php - How to update two mySQL tables and input primary key from first table into second table? -
my first table contains sorts of info videos such as: video title, video thumbnail, video category, etc. second table store key points of each video.. 1 video may have 3 key points example. these fields added or deleted dynamically using jquery.
i'd submit information @ once, , i'd link videos , key points using video's primary key.
alternatively link them using video's file name or that. seems sloppy way.
here code:
if (isset($_post['submit'])) { $myvideo->addvideo ($sequence, $_files['filename']['name'], $_post['vidtitle'], $_post['vidcat'], $_files['thumbname']['name']);
} else { echo $myvideo->error; } }
this method adding video database.
i introduce method adds key points database so:`
$myvideo->addpoints($keypoint, $minutes, $seconds);
i want go inside same if statement "addvideo" , want updated primary key first insert foreign key. how can accomplish this?`
check out mysql_insert_id(). retrieves recent insert id of current connection.
as far quick algorithm if data submitted @ 1 time:
- insert video record
- get last insert id
- loop on video meta data , insert records setting foreign key step 2.
Comments
Post a Comment