Mysql
 sql >> डेटाबेस >  >> RDS >> Mysql

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. MySQL:त्रुटि 1022 (23000):लिख नहीं सकता; तालिका '#sql-2b8_2' में डुप्लीकेट कुंजी

  2. mysql में गतिरोध से कैसे बचें?

  3. Postgresql में स्कोर/रैंक के साथ FULLTEXT क्वेरी

  4. एक सरणी को MySQL में कैसे स्टोर करें?

  5. डीबी ::कच्चे और वाक्पटु के साथ एक ही क्वेरी का उपयोग कर विभिन्न परिणाम