<?php 

include("config.php");

$id=$_POST['id'];

mysql_query("update hotel_room set room_no='$_POST[room_no]', rtype='$_POST[rtype]', rprice='$_POST[rprice]',srt_description='$_POST[srt_description]', description='$_POST[description]' where id='$id' limit 1");

$uploadDir = "room/";

if (!is_dir($uploadDir)) {
    mkdir($uploadDir, 0777, true);
}

foreach ($_FILES['images']['tmp_name'] as $key => $tmp_name) {

    $imageName = $_FILES['images']['name'][$key];
    $tmpPath   = $_FILES['images']['tmp_name'][$key];

    if ($tmpPath != "") {

        // unique name
        $newName = time() . "_" . rand(1000, 9999) . "_" . $imageName;

        // move file
        if (move_uploaded_file($tmpPath, $uploadDir . $newName)) {

            // insert into DB
            $sql = "INSERT INTO room_images (room,image) VALUES ('$id','$newName')";
            mysql_query("$sql");
        }
    }
}



	
header("location:add_room.php");
?>