sql >> Databáze >  >> RDS >> Mysql

Vložte data zaškrtávacího políčka do 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. Jak nainstalovat a nakonfigurovat Zabbix na Ubuntu 20.04

  2. Jak změnit formát data a času v T-SQL

  3. Podporuje Visual Studio Server Explorer vlastní poskytovatele databází?

  4. Účel SQLAlchemy nad MySQLdb