insert multiple depend on prev queries I need to insert multiple records into a table. The number of records depend on the result of another query. For example:I want to insert booking detail depend on number of room customer choose. If customer choose 2 room, inserting should run two times. How can I do that?

$fetch = mysql_query("SELECT r.room_id FROM room AS r WHERE 
(r.room_name  LIKE '$roomtype') AND r.room_id NOT IN (SELECT b.room_id 
FROM bookingdetail AS b WHERE b.datearr =  '$datearrive' OR b.datedep =  
'$datedepart LIMIT '$roomno')")or die(mysql_error());

$sql="INSERT INTO bookingdetail (booking_id, room_id, datearr, datedep) 
VALUES ('$bookingid', '$room_id', '$datearrive', '$datedepart')";
This problem can easily be solved by php...
Get the number of rooms selected from the first query and assign it to a variable and then loop the second query by the number of rooms choosen.