samedi 5 août 2017

code php edit database by checkbox

I want to select checkbox to edit database. one checkbox two tabel. table1 record username lastname . tabel2 file image.Now the data is not shown in inputname for update. code

            $servername = "localhost";
            $username = "root";
            $password = "123456";
            $dbname = "school";
            $conn = mysqli_connect($servername, $username, $password, $dbname);
            mysqli_query($conn, "SET character_set_results=utf8");
            mysqli_query($conn, "SET character_set_client=utf8");
            mysqli_query($conn, "SET character_set_connection=utf8");

            if (!$conn)
            {
            die('error connect' . mysqli_connect_error());
            }

            $db_select = mysqli_select_db($conn,$dbname);
            if (!$db_select) {
            die('errors select ' . mysqli_connect_error());

            $room_id = $_REQUEST['room_id'];                
            $sql = "SELECT * FROM room1 WHERE room_id ='$room_id'";
            $result = $conn->query($sql);
            $room_id = explode(',',$row['room_id']);
            $room_name = explode(',',$row['room_name']);
                 if ($result->num_rows ==1)                           
                      {
                       while($row = $result->fetch_assoc())
                      {
            if (mysqli_query($conn, $sql)) {    
            echo "edit comfirm"; 
                } else {
                echo "can not edit " . mysqli_error($conn);
                 }
                 }
                 }
             mysqli_close($conn); 




Aucun commentaire:

Enregistrer un commentaire