Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "camping";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // Start date
- $date = '2017-01-04';
- // End date
- $end_date = '2017-01-14';
- while (strtotime($date) <= strtotime($end_date)) {
- $sql = "INSERT INTO `availability` (`id`, `date`, `available`, `accommodation_id`) VALUES (NULL, '$date', '1', 1)";
- $date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
- }
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement