php - How to retrieve and insert ImageId? -


i have insert function inserts image filename in 'imagefile' field in "image" table, each row has it's own imageid auto number. example of below:

imageid    imagefile  23         orange.jpg 24         flowers.png 25         castle.png 26         orange.jpg 

what want insert imageid table questionid , sessionid table (image_question) can use imageid link image table image question table. how code when insert image details in table above, retrieve it's imageid , store in imageid in image_question table. example below:

imageid   sessionid  questionid  23        aaa        1 24        aaa        2 25        aaa        3 26        aaa        4 

i have coded insert values sessionid , questionid need retrieving , inserting imageid. below current code:

<?php  session_start();   //connect db  $i = 0;  $insertimage = array();  for($i = 0;  $i < $c; $i++ ){       $insertimage[] = "'". mysql_real_escape_string($_session['id'] ) .                      ($_session['initial_count'] > 1 ? $_session['sessioncount'] : '') ."' ,'".                      mysql_real_escape_string( $_post['numquestion'][$i] ) ."'";  }    $imagesql = "insert question (imageid, sessionid, questionid)      values (" . implode('), (', $insertimage) . ")";  echo($imagesql);  mysql_close();   ?> 

mysqli_insert_id() after query execute trick


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -