Пример #1
0
function callDB()
{
    $option = $_REQUEST['operation'];
    $table = $_REQUEST['target'];
    $selectSQL = '';
    $loadSql = '';
    $newSql = '';
    $updateSql = '';
    $name = '';
    $id = '';
    $param = '';
    switch ($table) {
        case 2:
            $tableName = 'project_info';
            if ($option == 'read') {
                $loadSql = "select p.ID, p.IMAGE,p.IMAGE_PATH, c.Name, p.CAPTION,p.CREATED, p.UPDATED from project_info p inner join category c on p.IMAGE_CATEGORY = c.ID where p.DELETED=0 and c.DELETED=0";
            }
            if ($option == 'select') {
                $id = $_REQUEST['RecId'];
                $selectSQL = "select p.ID,p.IMAGE,p.IMAGE_PATH, c.NAME, p.CAPTION from project_info p inner join category c on p.IMAGE_CATEGORY = c.ID where p.ID = {$id}";
            }
            if ($option == 'new') {
                $param = $_REQUEST['name'];
                $newSql = "insert into project_info (IMAGE, IMAGE_CATEGORY, CAPTION, IMAGE_PATH) VALUES ('{$param['0']}',(select ID from category where NAME= '{$param['1']}' and DELETED = 0),'{$param['2']}', '{$param['3']}')";
            }
            if ($option == 'update') {
                $param = $_REQUEST['name'];
                $id = $_REQUEST['id'];
                if (empty($param[3])) {
                    $updateSql = "update project_info set IMAGE='{$param['0']}',IMAGE_CATEGORY = (select ID from category where Name='{$param['1']}'), CAPTION ='{$param['2']}', UPDATED = now() where ID = {$id} and DELETED=0";
                } else {
                    $updateSql = "update project_info set IMAGE='{$param['0']}',IMAGE_CATEGORY = (select ID from category where Name='{$param['1']}'), CAPTION ='{$param['2']}', IMAGE_PATH = '{$param['3']}', UPDATED = now() where ID = {$id} and DELETED=0";
                }
            }
            break;
        case 4:
            $tableName = 'slider';
            if ($option == 'read') {
                $loadSql = "select * from slider where DELETED = 0";
            }
            if ($option == 'select') {
                $id = $_REQUEST['RecId'];
                $selectSQL = "select * from slider where ID={$id}";
            }
            if ($option == 'new') {
                $param = $_REQUEST['name'];
                $newSql = "insert into slider (IMAGE, HEAD_CAPTION, SUB_CAPTION, IMAGE_PATH) VALUES ('{$param['0']}','{$param['1']}','{$param['2']}', '{$param['3']}')";
                //print_r($newSql);
            }
            if ($option == 'update') {
                $param = $_REQUEST['name'];
                $id = $_REQUEST['id'];
                if (empty($param[3])) {
                    $updateSql = "update slider set IMAGE = '{$param['0']}', HEAD_CAPTION = '{$param['1']}' , SUB_CAPTION = '{$param['2']}' , UPDATED = now() where  ID = {$id} and DELETED= 0 ";
                } else {
                    $updateSql = "update slider set IMAGE = '{$param['0']}', HEAD_CAPTION = '{$param['1']}' , SUB_CAPTION = '{$param['2']}', IMAGE_PATH = '{$param['3']}' , UPDATED = now() where  ID = {$id} and DELETED= 0 ";
                }
            }
            break;
    }
    switch ($option) {
        case "read":
            //callread();
            echo json_encode(readRecords($loadSql));
            break;
        case "select":
            echo json_encode(readRecords($selectSQL));
            break;
        case "update":
            //$date = now();
            //echo($date);
            updateRecords($updateSql);
            if ($table == 2) {
                echo "<script>window.location = 'portfolio.php';</script>";
            } else {
                if ($table == 4) {
                    echo "<script>window.location = 'slider.php';</script>";
                }
            }
            break;
        case "delete":
            $id = $_REQUEST['RecId'];
            $sql = "update {$tableName} set DELETED = 1 where ID={$id} ";
            echo deleteRecords($sql);
            break;
        case "new":
            WriteRecords($newSql);
            if ($table == 2) {
                echo "<script>window.location = 'portfolio.php';</script>";
            } else {
                if ($table == 4) {
                    echo "<script>window.location = 'slider.php';</script>";
                }
            }
            break;
    }
}
function callDB()
{
    $option = $_REQUEST['operation'];
    //echo('option choosed'.$option);
    //$option="update";
    //$tableName=$_GET['table'];
    //$tableName='category';
    $table = $_REQUEST['target'];
    $selectSQL;
    $loadSql;
    $newSql;
    $updateSql;
    $name;
    $id;
    $param;
    switch ($table) {
        case 1:
            $tableName = 'category';
            //echo ' '.$tableName.' '.$option;
            if ($option == 'read') {
                $loadSql = "select * from category where DELETED = 0";
            }
            if ($option == 'select') {
                $id = $_REQUEST['RecId'];
                $selectSQL = "select * from category where ID={$id}";
            }
            if ($option == 'update') {
                $name = $_REQUEST['name'];
                //check same name for current record
                $match = "select NAME from category where NAME= '{$name}' and DELETED= 0 ";
                $result = readRecords($match);
                if ($result) {
                    echo 'duplicate';
                    return;
                } else {
                    $id = $_REQUEST['RecId'];
                    $match = "select NAME from category where NAME = '{$name}' and ID != {$id} and DELETED = 0 ";
                    $result = readRecords($match);
                    //print_r($result);
                    if ($result) {
                        //echo('in second update');
                        echo 'duplicate';
                        return;
                    } else {
                        //print_r('in update');
                        $updateSql = "update category set NAME='{$name}', UPDATED = now() where ID = {$id} and deleted=0";
                        //print_r($updateSql);
                    }
                }
            }
            if ($option == "new") {
                $name = $_REQUEST['name'];
                //check same name for current record
                $match = "select NAME from category where NAME= '{$name}' and DELETED= 0 ";
                $result = readRecords($match);
                if ($result) {
                    echo 'duplicate';
                    return;
                } else {
                    $newSql = "insert into category(NAME) values('{$name}')";
                }
            }
            break;
        case 3:
            $tableName = 'footer_info';
            //echo ' '.$tableName.' '.$option;
            if ($option == 'read') {
                $loadSql = "select * from footer_info where DELETED = 0";
            }
            if ($option == 'select') {
                $id = $_REQUEST['RecId'];
                $selectSQL = "select * from footer_info where ID={$id}";
            }
            if ($option == 'new') {
                $name = $_REQUEST['name'];
                //echo($name);
                $newSql = "insert into footer_info(ABOUT) values('{$name}')";
            }
            if ($option == 'update') {
                $name = $_REQUEST['name'];
                $id = $_REQUEST['RecId'];
                $updateSql = "update footer_info set ABOUT='{$name}', UPDATED = now() where ID = {$id} and deleted=0";
            }
            break;
    }
    //echo($table);
    switch ($option) {
        case "read":
            //callread();
            echo json_encode(readRecords($loadSql));
            break;
        case "select":
            echo json_encode(readRecords($selectSQL));
            break;
        case "update":
            //$date = now();
            //echo($date);
            //echo('in update'); die();
            echo updateRecords($updateSql);
            //echo "<script>window.location = 'fileUpload.php';</script>";
            break;
        case "delete":
            $id = $_REQUEST['RecId'];
            $sql = "update {$tableName} set DELETED = 1 where ID={$id} ";
            echo deleteRecords($sql);
            break;
        case "new":
            echo json_encode(WriteRecords($newSql));
            break;
    }
}
Пример #3
0
function createSubCatalogue($category)
{
    $columns = array("product_id", "name", "price", "image", "category");
    $table = "products";
    $productDetails = readRecords($table, $columns);
    $outerDivID = strtolower(str_replace(' ', '_', $category));
    ?>
		
		<div id="<?php 
    echo $outerDivID;
    ?>
" class="subcatalogue">	
			<h2><?php 
    echo $category;
    ?>
</h2>
			<?php 
    $name;
    $price;
    $image;
    $prodID;
    for ($x = 0; $x < count($productDetails); $x++) {
        if ($productDetails[$x]["category"] == $category) {
            $name = $productDetails[$x]["name"];
            $price = $productDetails[$x]["price"];
            $image = $productDetails[$x]["image"];
            $prodID = $productDetails[$x]["product_id"];
            $innerDivID = strtolower(str_replace(' ', '_', $name));
            ?>

					<div id="<?php 
            echo $innerDivID;
            ?>
">
						<a href="product.php?prodID=<?php 
            echo $prodID;
            ?>
">
						<img src="Images/<?php 
            echo $image;
            ?>
" alt="<?php 
            echo $name;
            ?>
"></a>

						<p  class="prodInfo"><?php 
            echo $name;
            ?>
<br><?php 
            echo $price;
            ?>
</p>
					</div>

					<?php 
        }
    }
    ?>
		</div>
		<?php 
}
Пример #4
0
		<!-- main image -->
        <div class="jumbotron" style="margin-left:10px; margin-right:10px; width=100vm">
            <div class="container" >
                <h1>NB GARDENS</h1>
                <h2>Gnome Is Where The Heart Is</h2>
            </div>
        </div>
		<h2 style="text-align:center;">Our Products</h2><br>
<!-- image slider -->
 <div id="myCarousel" class="carousel slide" data-interval="false" data-ride="carousel"
 style="width:500px; margin-left: auto; margin-right: auto;">

  <!-- Wrapper for slides -->
  <?php 
$columns = array('image', 'name', 'product_id');
$productDetails = readRecords('products', $columns);
?>
  <div class="carousel-inner" role="listbox">
  
    <div class="item active">
	<?php 
$image = $productDetails[0]['image'];
$name = $productDetails[0]['name'];
$prodID = $productDetails[0]['product_id'];
$link = "product.php?prodID=" . $prodID;
echo '<a href="' . $link . '"><img src="Images/' . $image . '" alt="' . $name . '" style="padding:10px;"></a>';
?>
	  <p style="text-align:center;"><?php 
echo $productDetails[0]['name'];
?>
 </p>
Пример #5
0
 } else {
     if ($type == "addRecord") {
         $message = addRecord($conn);
         $records = readRecords($conn);
     } else {
         if ($type == "editRecord") {
             $message = editRecord($conn);
             $records = readRecords($conn);
         } else {
             if ($type == "editCharactersRecord") {
                 $message = editCharactersRecord($conn);
                 $records = readRecords($conn);
             } else {
                 if ($type == "deleteRecord") {
                     $message = deleteRecord($conn);
                     $records = readRecords($conn);
                 } else {
                     if ($type == "addGameBuild") {
                         $message = addGameBuild($conn);
                         $gameBuilds = readGameBuilds($conn);
                     } else {
                         if ($type == "editGameBuild") {
                             $message = editGameBuild($conn);
                             $gameBuilds = readGameBuilds($conn);
                         } else {
                             if ($type == "deleteGameBuild") {
                                 $message = deleteGameBuild($conn);
                                 $gameBuilds = readGameBuilds($conn);
                             } else {
                                 $message = 'Site error. Action ' . $type . ' not recognized.';
                                 $success = false;