Thursday, 13 June 2019

Update data in mysql using php form

page name updatedata.php and Column in table : id , uid , upass , email.

 <!DOCTYPE html>
<html>
<head>
<title></title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="maindiv">
<div class="divA">
<div class="title">
<h2>Update Data </h2>
</div>
<div class="divB">
<div class="divD">
<p>Click On Menu</p>
<?php
$connection = mysql_connect("localhost", "root", "root password");
$db = mysql_select_db("db name", $connection);
if (isset($_GET['submit'])) {
$id = $_GET['did'];
$name = $_GET['dname'];
$email = $_GET['demail'];
$mobile = $_GET['dmobile'];

$query = mysql_query("update admin_log set
id='$id',uid='$name', email='$email', upass='$mobile' where id='$id'", $connection);
}
$query = mysql_query("select * from admin_log", $connection);
while ($row = mysql_fetch_array($query)) {
echo "<b><a href='updatedata.php?update={$row['id']}'>{$row['upass']}</a></b>";
echo "<br />";
}
?>
</div><?php
if (isset($_GET['update'])) {
$update = $_GET['update'];
$query1 = mysql_query("select * from admin_log where id=$update", $connection);
while ($row1 = mysql_fetch_array($query1)) {
echo "<form class='form' method='get'>";
echo "<h2>Update Form</h2>";
echo "<hr/>";
echo"<input class='input' type='hidden' name='did' value='{$row1['id']}' />";
echo "<br />";
echo "<label>" . "Name:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='dname' value='{$row1['uid']}' />";
echo "<br />";
echo "<label>" . "Email:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='demail' value='{$row1['email']}' />";
echo "<br />";
echo "<label>" . "Password:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='dmobile' value='{$row1['upass']}' />";


echo "</textarea>";
echo "<br />";
echo "<input class='submit' type='submit' name='submit' value='update' />";
echo "</form>";
}
}
if (isset($_GET['submit'])) {
echo '<div class="form" id="form3"><br><br><br><br><br><br>
<Span>Data Updated Successfuly......!!<br><br></span></div>';
}
?>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</div><?php
mysql_close($connection);
?>
</body>
</html>

Thursday, 30 May 2019

Use Of MySQL Where Clause in php 7.3

The WHERE clause is used to extract only those records that fulfill a specified condition.
where clause is a part of select command . it is used to fetch data from a table . we basically use this clause to filter out our results. by using where clause we can select particular set of records based specified condition.

create database name dbname
table name :  empInfo
column : id , name , eid,mob

create connection.php page

<?php

$con=mysqli_connect("localhost","username","password","dbname") or die(mysqli_error());


?>

create index.php 

<?php 

include("connection.php");

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>page title</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link href="style.css" rel="stylesheet" type="text/css" />



<style type="text/css">

<!--

.style4 { color: #0066CC;

font-weight: bold;

font-size: 16px;

}

-->

</style>

</head>

<body>

       

                      <?php

                      //select values from empInfo table where column=value

                     $data="SELECT * FROM empInfo where emp_id='devesh@gmail.com'";
$val=mysqli_query($con,$data);
echo "<table border='1'>";
echo "<tr><th>Emp_id</th><th>Name</th><th>Email</th><th>Mobile</th></tr>";

while(list($id,$name,$eid,$mob) =  mysqli_fetch_array($val))
{
echo "<tr>";
echo "<td>".$id."</td>";
echo "<td>".$name."</td>";
echo "<td>".$eid."</td>";
echo "<td>".$mob."</td>";
echo "</tr>";
}
echo "</table>";
 ?>

                          

                  <?php //}?>

              
</body>

</html>



Redirect http to https using .htaccess

Redirect your http page to https page using .htaccess file
create .htaccess file in your root folder and paste given code. Change red text to your domain name

<---- start code here ---->

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sakhihosting\.in [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.sakhihosting.in/$1 [R=301,L]


<---- end code here ---->

Redirect Specified Folder

If you want to force SSL on a specific folder, insert the code below into a .htaccess file placed in that specific folder:
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R=301,L]


Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folderwith your actual domain name and folder you want to force the SSL on.

Sunday, 12 May 2019

CoinPayments.net Payments Module for BoxBilling

CoinPayments.net Payments Module for BoxBilling
This module is modified from the PayPal module that comes with BoxBilling.

1. Upload the bb-library folder into your BoxBilling root directory.
2. In your BoxBilling admin page, go to Configuration, Payment gateways, New payment gateway and click the Install button to the right of CoinPayments.
3. Click the Edit Settings button in the Payment Gateways list to the right of CoinPayments.
4. Optionally enter a debug email address to receive IPN errors (recommended during testing).
5. Select "Yes" next to "Enabled:" and "Allow one time payments:".
6. Select "No" next to "Enable test mode:".
7. Click "Update" to save your settings.

And you should be all set.


<------------ Code Start --------------->
<?php
/**
 * CoinPayments.net Payment Gateway for BoxBilling
 * Based on the original PayPal module
 *
 * BoxBilling
 *
 * LICENSE
 *
 * This source file is subject to the license that is bundled
 * with this package in the file LICENSE.txt
 * It is also available through the world-wide-web at this URL:
 * http://www.boxbilling.com/LICENSE.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@boxbilling.com so we can send you a copy immediately.
 *
 * @copyright Copyright (c) 2010-2012 BoxBilling (http://www.boxbilling.com)
 * @license   http://www.boxbilling.com/LICENSE.txt
 * @version   $Id$
 */
class Payment_Adapter_CoinPayments
{
    private $config = array();
    private $error_msg = '';
   
    public function __construct($config)
    {
        $this->config = $config;
       
        if(!$this->config['merchant_id']) {
            throw new Exception('Payment gateway "CoinPayments" is not configured properly. Please update configuration parameter "CoinPayments.net Merchant ID" at "Configuration -> Payments".');
        }
       
        if(!$this->config['ipn_secret']) {
            throw new Exception('Payment gateway "CoinPayments" is not configured properly. Please update configuration parameter "CoinPayments.net IPN Secret" at "Configuration -> Payments".');
        }
       
        if($this->config['test_mode']) {
            throw new Exception('Payment gateway "CoinPayments" does not support Test Mode. You can enable the Litecoin Testnet for testing transactions however.');
        }
    }

    public static function getConfig()
    {
        return array(
            'supports_one_time_payments'   =>  true,
            'supports_subscriptions'     =>  false,
            'description'     =>  'Enter your CoinPayments.net Merchant ID and IPN Secret to start accepting payments by CoinPayments.',
            'form'  => array(
                'merchant_id' => array('text', array(
                            'label' => 'CoinPayments.net Merchant ID',
                            'validators'=>array(),
                    ),
                 ),
                'ipn_secret' => array('text', array(
                            'label' => 'CoinPayments.net IPN Secret',
                            'validators'=>array(),
                    ),
                 ),
                'debug_email' => array('text', array(
                            'label' => 'Debug Email (will receive copies of all IPN errors)',
                            'validators'=>array('EmailAddress'),
                    ),
                 ),
            ),
        );
    }

    public function getHtml($api_admin, $invoice_id, $subscription)
    {
        $invoice = $api_admin->invoice_get(array('id'=>$invoice_id));
        $buyer = $invoice['buyer'];
       
        $p = array(
            ':id'=>sprintf('%05s', $invoice['nr']),
            ':serie'=>$invoice['serie'],
            ':title'=>$invoice['lines'][0]['title']
        );
        $title = __('Payment for invoice :serie:id [:title]', $p);
        $number = $invoice['nr'];
       
        if($subscription) {
            //we don't support recurring subs, but we'll at least do the first payment
            $subs = $invoice['subscription'];
           
            $data = array();
            $data['cmd']                = '_pay';
            $data['reset']              = 1;
            $data['merchant']           = $this->config['merchant_id'];
            $data['item_name']          = $title;
            $data['item_number']        = $number;
            $data['want_shipping']      = 1;
            $data['allow_extra']        = 0; // Do not prompt payers to include a note with their payments. Allowable values for Subscribe buttons:
            $data['currency']           = $invoice['currency'];
            $data['amountf']            = $this->moneyFormat($invoice['total'], $invoice['currency']); // Regular subscription price.
            $data['success_url']        = $this->config['return_url'];
            $data['cancel_url']         = $this->config['cancel_url'];
            $data['ipn_url']            = $this->config['notify_url'];
            $data['invoice']            = $invoice['id'];

            //client data
            $data['address1'] = $buyer['address'];
            $data['city'] = $buyer['city'];
            $data['email'] = $buyer['email'];
            $data['first_name'] = $buyer['first_name'];
            $data['last_name'] = $buyer['last_name'];
            $data['zip'] = $buyer['zip'];
            $data['state'] = $buyer['state'];           
        } else {
            $data = array();
            $data['cmd']                = '_pay';
            $data['reset']              = 1;
            $data['merchant']           = $this->config['merchant_id'];
            $data['item_name']          = $title;
            $data['item_number']        = $number;
            $data['want_shipping']      = 1;
            $data['allow_extra']        = 0; // Do not prompt payers to include a note with their payments. Allowable values for Subscribe buttons:
            $data['currency']           = $invoice['currency'];
            $data['amountf']            = $this->moneyFormat($invoice['total'], $invoice['currency']);
            $data['taxf']               = $this->moneyFormat($invoice['tax'], $invoice['currency']);
            $data['success_url']        = $this->config['return_url'];
            $data['cancel_url']         = $this->config['cancel_url'];
            $data['ipn_url']            = $this->config['notify_url'];
            $data['invoice']            = $invoice['id'];
        }
       
        return $this->_generateForm('https://www.coinpayments.net/index.php', $data);
    }
   
    private function _errorAndDie($error_msg) {
    if ($this->config['debug_email']) {
$report = "AUTH User: |".$_SERVER['PHP_AUTH_USER']."|\n";
$report .= "AUTH Pass: |".$_SERVER['PHP_AUTH_PW']."|\n\n";

$report .= "Error Message: ".$error_msg."\n\n";

$report .= "POST Fields\n\n";
foreach ($_POST as $key => $value) {
$report .= $key . '=' . html_entity_decode($value, ENT_QUOTES, 'UTF-8'). "\n";
}

@mail($this->config['debug_email'], "CoinPayments.net Invalid IPN", $report);
}

throw new Exception('IPN Error: '.$error_msg);
// just in case
die('IPN Error: '.$error_msg);
    }

    public function processTransaction($api_admin, $id, $data, $gateway_id)
    {
      $ipn = $data['post'];
    if (!$this->_is_ipn_valid($ipn)) {
$this->_errorAndDie($this->error_msg);
}

  if (!isset($ipn['ipn_type']) || $ipn['ipn_type'] != 'button') {
$this->_errorAndDie('ipn_type != button, ignored.');
  }

      $tx = $api_admin->invoice_transaction_get(array('id'=>$id));
     
      if ($tx['status'] == 'processed') {
$this->_errorAndDie('Transaction has already been processed...');
      }

      if(!$tx['invoice_id']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'invoice_id'=>$data['get']['bb_invoice_id']));
}
       
if(!$tx['type']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'type'=>$ipn['ipn_type']));
}
       
if(!$tx['txn_id']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'txn_id'=>$ipn['txn_id']));
}
       
if(!$tx['txn_status']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'txn_status'=>$ipn['status_text']));
}
       
if(!$tx['amount']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'amount'=>$ipn['amount1']));
}
       
if(!$tx['currency']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'currency'=>$ipn['currency1']));
}

$invoice = $api_admin->invoice_get(array('id'=>$data['get']['bb_invoice_id']));
$client_id = $invoice['client']['id'];
if ($invoice['currency'] != $ipn['currency1']) {
$api_admin->invoice_transaction_update(array('id'=>$id, 'error'=>'Original currency does not match invoice currency!'));
$this->_errorAndDie('Original currency does not match invoice currency!');
}

$status = intval($ipn['status']);
if ($status >= 100 || $status == 2) {
        $bd = array(
            'id'            =>  $client_id,
            'amount'        =>  $ipn['amount1'],
            'description'   =>  'CoinPayments transaction '.$ipn['txn_id'],
            'type'          =>  'CoinPayments',
            'rel_id'        =>  $ipn['txn_id'],
        );
        $api_admin->client_balance_add_funds($bd);
        $api_admin->invoice_batch_pay_with_credits(array('client_id'=>$client_id));
        $d = array(
            'id'        => $id,
            'error'     => '',
            'error_code'=> '',
            'status'    => 'processed',
            'updated_at'=> date('c'),
        );
        $api_admin->invoice_transaction_update($d);                   
} else if ($status >= 0) {
        $d = array(
            'id'        => $id,
            'error'     => '',
            'error_code'=> '',
            'status'    => 'pending',
            'updated_at'=> date('c'),
        );
        $api_admin->invoice_transaction_update($d);                   
} else {
        $d = array(
            'id'        => $id,
            'error'     => '',
            'error_code'=> '',
            'status'    => 'canceled',
            'updated_at'=> date('c'),
        );
        $api_admin->invoice_transaction_update($d);                   
}
    }

    private function _is_ipn_valid($ipn)
    {   
if (!isset($ipn['ipn_mode'])) {
$this->error_msg  = 'IPN received with no ipn_mode.';
return FALSE;
}
if ($ipn['ipn_mode'] == 'hmac') {
if (!isset($_SERVER['HTTP_HMAC']) || empty($_SERVER['HTTP_HMAC'])) {
$this->error_msg  = 'No HMAC signature received.';
return FALSE;
}

$request = file_get_contents('php://input');
if ($request === FALSE || empty($request)) {
$this->error_msg  = 'Error reading POST data';
return FALSE;
}

$merchant = isset($ipn['merchant']) ? $ipn['merchant']:'';
if (empty($merchant)) {
$this->error_msg  = 'No Merchant ID passed';
return FALSE;
}
if ($merchant != trim($this->config['merchant_id'])) {
$this->error_msg  = 'Invalid Merchant ID';
return FALSE;
}

$hmac = hash_hmac("sha512", $request, trim($this->config['ipn_secret']));
if ($hmac != $_SERVER['HTTP_HMAC']) {
$this->error_msg  = 'HMAC signature does not match';
return FALSE;
}

return TRUE;
} else if ($ipn['ipn_mode'] == 'httpauth') {
if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] == trim($this->config['merchant_id'])) {
if (isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_PW'] == trim($this->config['ipn_secret'])) {
$merchant = isset($ipn['merchant']) ? $ipn['merchant']:'';
if (empty($merchant)) {
$this->error_msg  = 'No Merchant ID passed';
return FALSE;
}
if ($merchant != trim($this->config['merchant_id'])) {
$this->error_msg  = 'Invalid Merchant ID';
return FALSE;
}
return TRUE;
} else {
$this->error_msg  = 'IPN Secret not correct or no HTTP Auth variables passed. If you are using PHP in CGI mode try the HMAC method.';
}
} else {
$this->error_msg  = 'Merchant ID not correct or no HTTP Auth variables passed. If you are using PHP in CGI mode try the HMAC method.';
}
} else {
$this->error_msg  = 'Unknown ipn_mode.';
}
return FALSE;   
    }

    private function moneyFormat($amount, $currency)
    {
        return number_format($amount, 2, '.', '');
    }
   
private function _escapeForForm($data) {
if (defined('ENT_HTML401')) {
return htmlspecialchars($data,ENT_QUOTES|ENT_HTML401,'UTF-8');
} else {
return htmlspecialchars($data,ENT_QUOTES,'UTF-8');
}
}

    private function _generateForm($url, $data, $method = 'post')
    {
        $form  = '';
        $form .= '<form name="coinpayments_payment_form" action="'.$url.'" method="'.$method.'">' . PHP_EOL;
        foreach($data as $key => $value) {
            $form .= sprintf('<input type="hidden" name="%s" value="%s" />', $this->_escapeForForm($key), $this->_escapeForForm($value)) . PHP_EOL;
        }
        $form .=  '<input class="bb-button bb-button-submit" type="submit" value="Pay with Bitcoin, Litecoin, or other altcoins via CoinPayments.net" id="coinpayments_payment_button"/>'. PHP_EOL;
        $form .=  '</form>' . PHP_EOL . PHP_EOL;

        if(isset($this->config['auto_redirect']) && $this->config['auto_redirect']) {
            $form .= sprintf('<h2>%s</h2>', __('Redirecting to CoinPayments.net'));
            $form .= "<script type='text/javascript'>$(document).ready(function(){    document.getElementById('coinpayments_payment_button').style.display = 'none';    document.forms['coinpayments_payment_form'].submit();});</script>";
        }

        return $form;
    }
}


<-------------- Code End -------------------->

Saturday, 4 May 2019

Filter Contents and Filter products using PHP

we are going to learn how to filter contents and filter product using php and mysql. It helps user to view content on the webpage as per their preference also its save user time. Using filter feature user can find the relevant data from the numerous product list. In this tutorial we are going to deal with book as a product. In which we are going to create filters for category of book, price range andpublished year.


Creating database
reate the database by using following queries. The following SQL creates filter table which consist of title, category, price, year and cover(name of image) columns.
CREATE TABLE `filter` (
  `title` varchar(500) NOT NULL,
  `category` varchar(500) NOT NULL,
  `price` int(255) NOT NULL,
  `year` year(4) NOT NULL,
  `cover` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Now lets insert some records by using following queries.
INSERT INTO `filter` (`title`, `category`, `price`, `year`, `cover`) VALUES
('Say you are sorry', 'mystery', 3, 2017, 'syas.jpg'),
('You will know me', 'mystery', 4, 2016, 'ywkm.jpg'),
('Say you are sorry', 'adventure', 7, 2017, 'origin.jpg'),
('New York', 'fiction', 8, 2016, 'Allthebird.jpg'),
('The Outsider', 'mystery', 10, 2018, 'toutsider.jpg'),
('You will know me', 'adventure', 11, 2016, 'nfg.jpg'),
('The Outsider', 'adventure', 12, 2018, 'fallen.jpg'),
('The gone world', 'fiction', 14, 2017, 'ny2140.jpg'),
('All the birds in sky', 'fiction', 16, 2018, 'tgw.jpg');
create  dbconfig.php
<?php
$con = mysqli_connect("localhost","root","","technopoints");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>
Create index.php
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Filter Tutorial on Technopoints</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
  <style>

/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
@media screen and (max-width: 500px) {
    .column {
        width: 100%;
    }
}
.thumbnail img{
    max-width: 100%; /* do not stretch the bootstrap column */
}

.img-wrapper{
width: 100%;
padding-bottom: 100%; /* your aspect ratio here! */
position: relative;
}

.img-wrapper img{
position: absolute;
top: 0; 
bottom: 0; 
left: 0; 
right: 0;
min-height: 50%;
max-height: 100%;
min-width:100%/* optional: if you want the smallest images to fill the .thumbnail */
}
</style>
</head>
<body>

<div class="container">
  <h2>Technopoints: Filter</h2>
  <p>From below dropdown menus you can apply filter</p>
  <form action="" method="post">
    <div class="row">
    <div class="col-sm-3">
        <div class="form-group">
            <select class="form-control" name="category">
                <option value="">Select Category</option>
                <option value="fiction">Science Fiction</option>
                <option value="Mystery">Mystery</option>
<option value="Adventure">Adventure</option>
            </select>
        </div>
    </div>
    <div class="col-sm-3">
        <div class="form-group">
            <select class="form-control" name="year">
                <option value ="">Year of Publishing</option>
                <option value="2016">2016</option>
                <option value="2017">2017</option>
<option value="2018">2018</option>
            </select>
        </div>
    </div>
    <div class="col-sm-3">
        <div class="form-group">
            <select class="form-control" name="price">
                <option value="">Select Price Range</option>
                <option value="range1">01$ - 05$</option>
                <option value="range2">05$ - 10$</option>
<option value="range3">10$ - 15$</option>
            </select>
        </div>
    </div>
<button type="submit" class="btn btn-primary">Apply</button>
</div>
</form>
</div>
<center><h2>Apply Filter To Check Result</h2><br><center>
<div class="container-fluid">
    <div class="row"><?php
         error_reporting( error_reporting() & ~E_NOTICE );
if(isset($_POST['price'])) { if($_POST['price']=='range1'){
$low = 1; $high = 5;
}
if($_POST['price']=='range2'){
$low = 5; $high = 10;
}
if($_POST['price']=='range3'){
$low = 10; $high = 15;
} }
@$category = $_POST['category'];
@$year = $_POST['year'];
//@$price = $_POST['price'];
include 'dbconfig.php';
if(isset($_POST['price']) && isset($_POST['category']) && isset($_POST['year'])) { $qry = "SELECT * FROM filter
WHERE price BETWEEN $low AND $high AND year = $year AND category ='$category'"; }
if(isset($_POST['price']) && isset($_POST['category']) && $_POST['year']==NULL){
$qry = "SELECT * FROM filter
WHERE price BETWEEN $low AND $high AND category ='$category'";
}
if(isset($_POST['category']) && isset($_POST['year']) && $_POST['price']==NULL){
$qry = "SELECT * FROM filter
WHERE year = $year AND category ='$category'";
}
if(isset($_POST['price']) && isset($_POST['year']) && $_POST['category']==NULL){
$qry = "SELECT * FROM filter
WHERE price BETWEEN $low AND $high AND year = $year";
}
if(isset($_POST['category']) && $_POST['year']==NULL && $_POST['price']==NULL){
$qry = "SELECT * FROM filter
WHERE category ='$category'";
}
if($_POST['category']==NULL && isset($_POST['year']) && $_POST['price']==NULL){
$qry = "SELECT * FROM filter
WHERE year =$year";
}
if($_POST['category']==NULL && $_POST['year']==NULL && isset($_POST['price'])){
$qry = "SELECT * FROM filter
WHERE price BETWEEN $low AND $high";
}
if($_POST['category']==NULL && $_POST['year']==NULL && $_POST['price']==NULL){
$qry = "SELECT * FROM filter";
}
$result = mysqli_query($con,$qry);
$num = mysqli_num_rows($result);
  if($num > 0) while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ ?>
        <!-- item -->
        <div class="col-xs-4 col-sm-2">
            <div class="thumbnail">
                <div class="img-wrapper">
                    <img src="cover/<?php echo $row['cover'];?>" alt="400">
                </div>
                <div class="caption text-center">Title:<?php echo $row['title'];?></div><!-- optional -->
<div class="caption text-center">Publishing Year:<?php echo $row['year'];?></div>
<div class="caption text-center">Category:<?php echo $row['category'];?></div>
<div class="caption text-center">Price:<?php echo $row['price'].'$';?></div>
</div>
        </div>
           <?php }else{
   echo "<h4>No Result Found</h4>"; } ?>
</div>
</div>
</body>
</html>