Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Masukkan data kotak centang ke mysql

    # Please Try again below code. #  

      <?php 
    if($_SERVER['HTTP_HOST'] == 'localhost:8080') {
        $servername = "localhost";
        $username = "root";
        $password = "";
        $db = 'test';
    }

    $conn = mysql_connect($servername, $username, $password);
    if ($conn) {
        mysql_select_db($db, $conn) or die('Could not select database.');
    }

    if(isset($_POST['submit'])){
        $monday = isset($_POST['day_name']['monday']) ? $_POST['day_name']['monday'] : 0;
        $tuesday = isset($_POST['day_name']['tuesday']) ? $_POST['day_name']['tuesday'] : 0;
        $wednesday = isset($_POST['day_name']['wednesday']) ? $_POST['day_name']['wednesday'] : 0;
        $thursday = isset($_POST['day_name']['thursday']) ? $_POST['day_name']['thursday'] : 0;
        $friday = isset($_POST['day_name']['friday']) ? $_POST['day_name']['friday'] : 0;

        //echo "INSERT INTO `available_day` (`monday`, `tuesday`, `wednesday`, `thursday`, `friday`) VALUES ('".$monday."', '".$tuesday."', '".$wednesday."', '".$thursday."', '".$friday."')"; 

        $sql_add = mysql_query("INSERT INTO `available_day` (`monday`, `tuesday`, `wednesday`, `thursday`, `friday`) VALUES ('".$monday."', '".$tuesday."', '".$wednesday."', '".$thursday."', '".$friday."')");

        if(!$sql_add)
        {
            die('could not add data'.mysql_error());
        }

        $message="Successfully Added ID No: ".mysql_insert_id();
        echo "<script type='text/javascript'>alert('$message');   window.location.href='index6.php';</script>";

    }

?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="contact_form" enctype='multipart/form-data'>
  <div class="form-group" >
       <input type="checkbox" name="day_name[monday]" value="1">Mon<br>
       <input type="checkbox" name="day_name[tuesday]" value="1"> Tues<br>
       <input type="checkbox" name="day_name[wednesday]" value="1"> Wed<br>
       <input type="checkbox" name="day_name[thursday]" value="1"> Thu<br>
       <input type="checkbox" name="day_name[friday]" value="1"> Fri<br>

    <input name="submit" type ="submit" class="btn btn-default" style="border-radius: 0px; background-color: midnightblue; box-shadow: 2px 2px 2px #888888; color: white;">
  </div> 

</form>


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Apakah Tampilan MySql Dinamis dan Efisien?

  2. menggabungkan hasil query mysql SUM() menggunakan inner join

  3. Laravel 5.3 Membuat Model Pengembalian Bidang tidak memiliki nilai default

  4. Nama Kolom Dinamis di MYSQL

  5. Kesalahan saat menyambung ke database:(menggunakan kelas org.gjt.mm.mysql.Driver) Pernyataan (1) tidak memiliki kursor terbuka