i use Bootstrap’s cards and php but i don't want to show a card per line
screen 1
i want to show Bootstrap’s card two per line like this:
screen 2
what can i do ?
this is my code:
<?php
$no_pharmacies_par_page = 5;
if (isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$ph = $no_pharmacies_par_page * $page - $no_pharmacies_par_page;
$sql_select_pharma = "SELECT * FROM pharmacies WHERE pharmacie_garde = 1 ORDER BY id desc LIMIT {$ph} ,{$no_pharmacies_par_page} ";
$res_sql_select_pharma = mysqli_query($dbconnection, $sql_select_pharma);
while ($rowpharma = mysqli_fetch_assoc($res_sql_select_pharma))
{
$id_pharma = $rowpharma['id'];
$nom_pharma = $rowpharma['nom_pharma'];
$pharma_syndicat = $rowpharma['nom_syndicat'];
$date_debut = $rowpharma['date_deb'];
$pharma_modif_date = $rowpharma['date_fin'];
$image_pharmacie = $rowpharma['image_pharmacie'];
$adresse_pharmacie = $rowpharma['adresse_pharma'];
$tel_pharmacie = $rowpharma['tel_pharmacie'];
$pharma_garde = $rowpharma['pharmacie_garde'];
$email_pharmacie = $rowpharma['email_pharmacie'];
?>
<div class="card-deck">
<div class="card">
<img class="card-img-top" src="admin/images/pharmacides/<?php echo $image_pharmacie; ?>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title"><?php echo $nom_pharma; ?></h5>
<p class="card-text"><?php echo substr($adresse_pharmacie, 0, 80) . "...";?></p>
</div>
<div class="card-footer">
<small class="text-muted"><?php echo $date_debut; ?></small>
</div>
</div>
</div>
<?php } ?>
Replace your html code with this and it'll do the required job.
<div class="container">
<div class="row">
<!-- Put Your For loop here to loop through your data -->
<div class="col-6">
<div class="card-deck">
<div class="card">
<img class="card-img-top" src="admin/images/pharmacides/<?php echo $image_pharmacie; ?>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title"><?php echo $nom_pharma; ?></h5>
<p class="card-text"><?php echo substr($adresse_pharmacie, 0, 80) . "...";?></p>
</div>
<div class="card-footer">
<small class="text-muted"><?php echo $date_debut; ?></small>
</div>
</div>
</div>
</div>
</div>
</div>
Related
How do i disable and enable an anchor tag based on order_status condition? I want to make my receipt button only be able to click when the order_status been updated to ($irow['order_status'] == 5. It would be much appreciated if you all can provide me a code demo to show me how should I implement this using jquery. Thanks!
<div class="container mt-3 mb-5">
<div class="row form-group">
<?php
$total_price = 0.00;
$total_quantity = 0;
$sql = "SELECT *, sum(purchase_price) purchase_price, sum(quantity) quantity FROM ordered_items WHERE user_id = '$user_id' GROUP BY order_id ORDER BY order_datetime DESC";
$query = $conn->query($sql);
if (!mysqli_num_rows($query)) {
echo '
<div class="col-12 text-center">
<div class="alert alert-danger">
<strong><span class="iconify" data-icon="ic:round-remove-shopping-cart" data-width="30px" data-height="30px" data-inline="false"></span> You have no order</strong>
</div>
</div>
';
} else {
while ($row = $query->fetch_assoc()) {
$total_price = $row['purchase_price'];
if($total_price < 500.00 && $row['item_deliver_method'] == 'Delivery'){
$grand_total = $total_price + 10.00;
}else{
$grand_total = $total_price;
}
$total_quantity = $row['quantity'];
//$grand_total = $row['grand_total'];
?>
<div class="col-12 form-group orderidfocus">
<div class="product-wrapper" id="<?php echo $row['order_id']; ?>">
<p class="pl-2 pt-2 pr-2">OrderID: <?php echo $row['order_id']; ?>
</br><?php echo $row['item_deliver_method']; ?> Date: <?php echo $row['delivery_date']; ?></p>
<hr style="border: 0.5px dashed #DBDBDB;">
<?php
$isql = "SELECT * FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id WHERE ordered_items.order_id = '".$row['order_id']."' ";
$iquery = $conn->query($isql);
while ($irow = $iquery->fetch_assoc()) {
if($irow['order_status'] == 1) {
$order_status = '<div class="badge-secondary font-italic p-1">Waiting for Response </div>';
}
if($irow['order_status'] == 2) {
$order_status = '<div class="badge-warning font-italic p-1">Preparing</div>';
}
if($irow['order_status'] == 3) {
$order_status = '<div class="badge-info font-italic p-1">In Delivery</div>';
}
if($irow['order_status'] == 4) {
$order_status = '<div class="badge-danger font-italic p-1">Ready to Pick up</div>';
}
if($irow['order_status'] == 5) {
$order_status = '<div class="badge-success font-italic p-1">Completed</div>';
}
?>
<div class="row h-100 pl-2 pr-2 form-group">
<div class="col-12">
<small class="float-right"><?php echo $order_status; ?></small>
</div>
<div class="col-3 my-auto form-group">
<img class="order-page-img-thumbnail" src="images/product-main/<?php echo $irow['product_photo']; ?>" alt="">
</div>
<div class="col-5 pl-0 pr-0 my-auto form-group">
<div class="product-title"><?php echo $irow['product_title']; ?></div>
</div>
<div class="col-4 pl-0 my-auto form-group">
<div class="product-price" style="text-align: right;">
RM<?php echo $irow['product_price']; ?>/<?php echo $irow['product_quantity']; ?><br>
<span style="color: #00644C;">X<?php echo $irow['quantity']; ?></span>
</div>
</div>
</div>
<?php } ?>
<hr style="border: 0.5px dashed #DBDBDB;">
<div class="row justify-content-end pl-2 pr-1">
<div class="col-3 my-auto form-group pr-0">
<p class="cat-title" style="text-align: left;font-size: 13px;">Qty: <?php echo $total_quantity; ?>KG</p>
</div>
<div class="col-5 my-auto form-group pl-0">
<p class="cat-title" style="text-align: right;font-size: 13px;">Amount: RM<?php echo number_format($grand_total,2); ?></p>
</div>
<div class="col-4 form-group pull-right text-center pl-0">
<a id="receiptbtn" target="_blank" href="receipt.php?order_id=<?php echo $row['order_id']; ?>" class="btn addtocart" style="font-size: 12px;"><span class="iconify" data-icon="bx:bx-download" data-inline="false"></span> Receipt</a>
</div>
</div>
</div>
</div>
<?php
}
}
?>
I am trying to add products dynamically from SQL database and using Bootstrap here but it shows my product on next line even if I am not using row the same result shown.
Here is my code and output.
include ("connection.php");
$sql = "select * from products";
$result = mysqli_query($con,$sql);
while ($row = $result->fetch_assoc())
{
?>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="card" style="width: 18rem;">
<img src="<?php echo $row['Pimage'] ?>" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><?php echo $row['Pname'] ?></h5>
<p class="card-text"><?php echo $row['Pdesc'] ?></p>
<P><?php echo $row['Pprice'] ?>PKR</P>
ADD To Cart
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
You should do something like this
<div class="container">
<div class="row">
<?php
include ("connection.php");
$sql = "select * from products";
$result = mysqli_query($con,$sql);
while ($row = $result->fetch_assoc()){
?>
<div class="col-lg-3">
<div class="card" style="width: 18rem;">
<img src="<?php echo $row['Pimage'] ?>" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><?php echo $row['Pname'] ?></h5>
<p class="card-text"><?php echo $row['Pdesc'] ?></p>
<P><?php echo $row['Pprice'] ?>PKR</P>
ADD To Cart
</div>
</div>
</div>
<?php
}
?>
</div>
In that way you will have 4 columns of products
Following is my code I am displaying details as 3 columns per row using Bootstrap class row.
I tried like changing div and some condition
<div class="container">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span> </span><?php echo $lclArea?></i>
<!-- See Profile -->
</div>
</div>
<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.
Change your code like this
<div class="container">
<div class="row">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title">
<?php echo $lclUserName?>
</h4>
<p class="card-text" style="font-size: 25px;">
<?php echo $lclCategory?>
</p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;">
<span>
</span>
<?php echo $lclArea?>
</i>
<!-- See Profile -->
</div>
</div>
</div>
<?php
}
?>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...
</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
Hi I am new in PHP but I want to Sum my amount and display it on the page currently I am doing like this but it is not showing.
<div class="col-md-4 col-lg-4">
<div class="panel panel-bordered panel-black">
<div class="panel-heading">
<h3 class="panel-title"><?php echo translate('Total Amount ');?></h3>
</div>
<div class="panel-body">
<div class="text-center">
<h1>
<?php
echo $this->db->select('SUM(amount) as Total');
$getData = $this->db->get_where('tablename',array('amount = '!=0))->first_row();
echo $getData->Total;
?>
</h1>
</div>
</div>
</div>
</div>
try this
<?php
$data = $this->db->get_where('tablename',array('amount = '=>1))->sum(amount)->result();
foreach($data as $row):
echo $row['amount']; //if array output
echo $row->amount; //object output
endforeach;
?>
<div class="col-md-4 col-lg-4">
<div class="panel panel-bordered panel-black">
<div class="panel-heading">
<h3 class="panel-title"><?php echo translate('Total Amount ');?></h3>
</div>
<div class="panel-body">
<div class="text-center">
<h1>
<?php
echo $this->db->select('SUM(amount) as Total');
$getData = $this->db->get_where('tablename',array('amount = '!=0))->first_row();
echo $getData->Total;
?>
</h1>
</div>
</div>
</div>
</div>
I have mysql database with two tables.categories and products.
categories
id
parent_id
category_name
image
status
products
id
category_id
product_name
product_description
image
status
Question
Using php code how to go to the products page after the n level categories?
Below is my php code.Thats going to the subcategories.but i am confused with the condition to go to the products page.
<?php
$category_id = $_GET['id'];
# Get categories
$categories = array();
$qry = mysql_query("SELECT * FROM categories
WHERE parent_id='".$category_id."' AND status = '1'")
or die(mysql_error());
# Get totals
$qry_total = "SELECT COUNT(*) FROM categories
WHERE parent_id='".$category_id."' AND status = '1'";
$total_qry = mysql_query($qry_total) or die(mysql_error());
list($total) = mysql_fetch_array($total_qry);
?>
<!--Content Side-->
<div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
<section class="blog-container">
<div class="row clearfix">
<!--Products Post-->
<?php
while($row = mysql_fetch_array($qry))
{ if($total==0){?>
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12 blog-post wow fadeInLeft" data-wow-delay="0ms" data-wow-duration="1500ms">
<a href="<?php echo $root_path.'products.php?id='.$row['parent_id']?>">
<article class="column-inner">
<figure class="image-box">
<?php if(!empty($row['image'])) {?>
<img src="<?php echo $root_path;?>timthumb.php?src=<?php echo $root_path.#$row['image']?>&q=400&w=250&h=200&zc=2" alt="">
<?php } else{ ?>
<img src="<?php echo $root_path;?>timthumb.php?src=<?php echo $root_path."images/resource/no-photo.gif"?>&q=400&w=250&h=200&zc=2" alt="">
<?php } ?>
</figure>
<div class="lower-part">
<div class="post-title" ><h3><?php echo $row['category_name']; ?></h3></div>
</div>
</article>
</a>
</div>
<?php } else{
?>
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12 blog-post wow fadeInLeft" data-wow-delay="0ms" data-wow-duration="1500ms">
<a href="<?php echo $root_path.'product_categories.php?id='.$row['id']?>">
<article class="column-inner">
<figure class="image-box">
<?php if(!empty($row['image'])) {?>
<img src="<?php echo $root_path;?>timthumb.php?src=<?php echo $root_path.#$row['image']?>&q=400&w=250&h=200&zc=2" alt="">
<?php } else{ ?>
<img src="<?php echo $root_path;?>timthumb.php?src=<?php echo $root_path."images/resource/no-photo.gif"?>&q=400&w=250&h=200&zc=2" alt="">
<?php } ?>
</figure>
<div class="lower-part">
<div class="post-title" ><h3><?php echo $row['category_name']; ?></h3></div>
</div>
</article>
</a>
</div>
<?php } } ?>
</div>
</section>
</div>
<!--Content Side-->