Ejemplo n.º 1
0
 static function Exists($strFolder, $oneStr = null, $twoStr = null, $threeStr = null)
 {
     switch (func_num_args()) {
         case 1:
             $r = Exists($strFolder);
             break;
         case 2:
             $r = Exists($strFolder, $oneStr);
             break;
         case 3:
             $r = Exists($strFolder, $oneStr, $twoStr);
             break;
         default:
             $r = Exists($strFolder, $oneStr, $twoStr, $threeStr);
     }
     return $r;
 }
Ejemplo n.º 2
0
}
function numOfCo($ISBN, $name)
{
    $db = new mysqli('localhost', 'root', '', 'library');
    $result = $db->query("SELECT NumberOfCopies FROM book WHERE ISBN='{$ISBN}' and name = '{$name}'");
    $row = mysqli_fetch_array($result);
    $va = intval($row['NumberOfCopies']);
    return "" . $va;
}
if (isset($_POST['submit'])) {
    echo "Test";
    $bookName = $_POST['BookName'];
    $ISBN = $_POST['ISBN'];
    $AuthorName = $_POST['author'];
    $db = new mysqli('localhost', 'root', '', 'library');
    if (Exists($ISBN, $bookName) == false) {
        $insertBook = $db->query("INSERT INTO book (ISBN,name,AuthorName,NumberOfCopies) VALUES ('{$ISBN}','{$bookName}','{$AuthorName}',1)");
        //header("Location: #ViewAllBooks");
        echo "ADDED ";
    } else {
        $cop = add($ISBN, $bookName);
        $update = $db->query("UPDATE book SET NumberOfCopies='{$cop}' WHERE ISBN='{$ISBN}' and name = '{$bookName}'");
    }
}
if (isset($_POST['submit2'])) {
    $bookName = $_POST['BookName'];
    $ISBN = $_POST['ISBN'];
    $db = new mysqli('localhost', 'root', '', 'library');
    if (numOfCo($ISBN, $bookName) == "0") {
        echo "there is no available copies of that book ";
    } else {