Esempio n. 1
0
<?php

include 'mysqlconn.php';
$connexion = new mySqlX();
$query = "SELECT * FROM item";
$result = $connexion->selectDB($query);
$r = array();
foreach ($result as $row => $key) {
    //echo "<b>Key:</b> $k - <b>Value:</b> $value || ";
    echo "\t\n\t\t<div class='row item'>\n\t\t\t<div class='col-xs-6'><img src='" . $key['item_image_url'] . "' /></div>\n\t\t\t<div class='col-xs-6'>\n\t\t\t\t<h2>" . $key['item_name'] . "</h2>\n\t\t\t\t<p>" . $key['item_description'] . "</p>\n\t\t\t\t<p>\n\t\t\t\t  <a class='btn btn-lg btn-primary' href='#' role='button'>Book it &raquo;</a>\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t</div>\n\t\t";
    echo "<br>";
}
Esempio n. 2
0
<?php

session_start();
include 'mysqlconn.php';
//echo "DATE PICKED: ".$_SESSION['datepicked'];
if (!empty($_POST)) {
    $toins = array($_POST['item_id'], $_POST['start_time'], $_POST['end_time'], $_POST['name'], $_POST['last_name'], $_POST['email'], $_POST['phone'], $_POST['comments']);
    $connexion = new mySqlX();
    //Check if there is another reservation for this period of time
    /*
    $query = "SELECT * FROM reservation WHERE item_id=".$_POST['item_id']." AND start_time=".$_POST['start_time']." BETWEEN start_time AND end_time";
    $result = $connexion->selectDB($query);
    if(!empty($result)){
    	echo "There is a reservation already for this time";
    }
    */
    $query = "INSERT INTO reservation (item_id, start_time, end_time, name, last_name, email, phone, comments)\n\t\t\tVALUES('" . $toins[0] . "', '" . $toins[1] . "', '" . $toins[2] . "', '" . $toins[3] . "', '" . $toins[4] . "', '" . $toins[5] . "', '" . $toins[6] . "', '" . $toins[7] . "')";
    $connexion->insertDB($query);
}
Esempio n. 3
0
function checkAvailability($date)
{
    $connexion = new mySqlX();
    $query = "SELECT * FROM reservation WHERE item_id=" . $_POST['item_id'] . " AND start_time=" . $_POST['start_time'] . " BETWEEN start_time AND end_time";
    $result = $connexion->selectDB($query);
    return empty($result);
}
Esempio n. 4
0
    }
    public function insertDB($conn, $query)
    {
        if ($conn->query($sql) === TRUE) {
            echo "New record created successfully";
        } else {
            echo "Error: " . $sql . "<br>" . $conn->error;
        }
    }
    public function selectDB($query)
    {
        $this->connectDB();
        $conn = $this->myconn;
        $result = $conn->query($query);
        if ($result->num_rows <= 0) {
            echo "0 results";
        } else {
            // output data of each row
            //print keys and values of the SELECT query
            foreach ($result as $key) {
                foreach ($key as $k => $value) {
                    echo "<b>Key:</b> {$k} - <b>Value:</b> {$value} || ";
                }
                echo "<br>";
            }
        }
    }
}
$connexion = new mySqlX();
$query = "SELECT * FROM user";
$connexion->selectDB($query);