Show php image field only uploaded field - php

i have 3 image field like this
<?php echo $row['thumbnail1']; ?>
<?php echo $row['thumbnail2']; ?>
<?php echo $row['thumbnail3']; ?>
if there only one exp thumbnail1 is have image..
how to show
and how if only image 1 and 2 have data..
please help how to show php query if there only 1 or 2 and 3 image upload
this css style
<div class="col-xs-12">
<img src="#" class="w-full">
</div>
<!-- IF only 2 image available uploaded USE this -->
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<!-- IF only ALL/3 image available uploaded USE this -->
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
</div>
dsa sdas

Replace your old code with this (Someone edited So i have Re writtent the code again) :
<?php
if(isset($row['thumbnail1']))
{
?>
<div class="col-xs-12">
<img src="#" class="w-full">
</div>
<?php } ?>
<!-- IF only 2 image available uploaded USE this -->
<?php
if(isset($row['thumbnail2']))
{
?>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<?php } ?>
<!-- IF only ALL/3 image available uploaded USE this -->
<?php
if(isset($row['thumbnail3']))
{
?>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<?php } ?>
Give me the update, if you have tested.

Related

WordPress content layout with Bootstrap

I'm trying to pull wordpress content to the grid structure created with Bootstrap. But I don't want to create separate query for each column. How can I pull content from the same category in a single query? My codes are as follows.I want to show the last 3 items added
<div class="container">
<?php query_posts('showposts=3&orderby=date&cat=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="row">
<div class="col-8">
<img src="" class="img-fluid rounded" alt="...">
</div>
<div class="col-4">
<img src="" class="img-fluid mb-3 rounded" alt="...">
<img src="" class="img-fluid rounded" alt="...">
</div>
</div>
<?php endwhile; ?>
</div>
what i want to do
<div class="container">
<div class="row">
<?php $i = 1; query_posts('showposts=3&orderby=date&cat=1'); ?>
<div class="col-8">
<?php while (have_posts()) : the_post(); ?>
<?php if($i==1){ ?>
<img src="" class="img-fluid rounded" alt="...">
</div>
<div class="col-4">
<?php } elseif($i==2){ ?>
<img src="" class="img-fluid mb-3 rounded" alt="...">
<?php } else { ?>
<img src="" class="img-fluid rounded" alt="...">
<?php } $i++; endwhile; ?>
</div>
</div>
</div>
click the picture for the problem
else created a problem. Also the 2 contents in the right column are the same. I wanted it to be different.

I need to include images into my gallery that are saved in my database

I need my gallery to show images that are saved within my database please. So rather than me using the images source tag, I need the gallery to be filled with what's saved in the database please. So essentially showing the user all the images that ONLY belong to them if that makes sense? I guess the html code of the gallery should fall within the php while loop ?
The html gallery code:
<div class="row">
<div class="grid-full">
<h3>ALL OF MY COMPETITION ENTRIES</h3>
<div class="masonry">
<div class="item">
<img alt src="Images/Nude.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/LakeDistrict.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/MarbleCase.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/HeadwoodBeach.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/MacDesk.png" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/CoffeeonTable.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/SilverMarble.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Peonies.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Trousers.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Greys.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Sunset.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Grey2.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Nature.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/autumn.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Tulips.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Pink.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/Outfit.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/BandW.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/TheLakeDistrict.jpg" class="ImgRound">
</div>
<div class="item">
<img alt src="Images/FlowerTable.jpg" class="ImgRound">
</div>
</div>
</div>
</div>
My Tables:
I think my PHP query would look something like this:
<?php
$query = "SELECT * FROM `tblImage` WHERE `fldMemberID` = 1";
$result = $conn -> query($query);
while($row = $result -> fetch_assoc()) {
?>
<img src="<?php echo $row['fldFilePath']; ?>"> <br>
<?php
}
$conn -> close();
?>
UPDATE: After running the code, the following errors I get this appear where the gallery should be:
The answer was given by another user #RiggsFolly in the comments, further up in the code I had used a $conn -> close(); by deleting this the code ran fine.

How To Change Footer Power By And Add Store Name

I am new to opencart,i am trying to change the store name in footer.
please answer me fast.
Go to Catalog/view/theme/default/template/common/footer.tpl
<div class="container-fluid bottom-footer">
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<p>Copyright 2016. Cartridgewala.com. All Rights Reserved.</p>
</div>
<div class="col-sm-12 text-center">
<p><img src="<?php echo 'image/weaccept.png'; ?>" title=" " alt=" " class="img-responsive" style=" display:inline-block" /></p>
</div>
</div>
</div>

Single php while one three different classes of images

i am using a main fours divs first div has class ad1, second and third div has class ad2 and then last div has class ad3...
i want to display 4 images from database
How to do it through while loop, please help, Thanks :)
here is html code and the php code....
<div class="col-md-9 hidden-sm hidden-xs">
<div class="col-md-1"></div>
<div class="col-md-2">
<div class="ad1">
<img src="" alt="">
</div>
</div>
<div class="col-md-2">
<div class="ad2">
<img src="" alt="">
</div>
</div>
<div class="col-md-2">
<div class="ad2">
<img src="" alt="">
</div>
</div>
<div class="col-md-5">
<div class="ad3">
<img src="" alt="">
</div>
</div>
</div>
php code is
<?php
$query = "SELECT * FROM headerimages limit 4";
$result = mysqli_query($con, $query) or die(mysqli_error($query));
while ($row = mysqli_fetch_array($result))
{?>
<?php
}
?>
First of all I recommend to use pdo database driver.
In your code the fast fix will be to assign result to array and simply echo it in the view.
$result = array();
while ($row = mysqli_fetch_array($result))
{
$result[]=$row['img'];
}
and in view echo it
<div class="col-md-9 hidden-sm hidden-xs">
<div class="col-md-1"></div>
<div class="col-md-2">
<div class="ad1">
<img src="<?=$result[0]?>" alt="">
</div>
</div>
<div class="col-md-2">
<div class="ad2">
<img src="<?=$result[1]?>" alt="">
</div>
</div>
<div class="col-md-2">
<div class="ad2">
<img src="<?=$result[2]?>" alt="">
</div>
</div>
<div class="col-md-5">
<div class="ad3">
<img src="<?=$result[3]?>" alt="">
</div>
</div>
</div>

Making Photo Grid with Different size images

Ok, may be its really simple. but, I can't figure it out how to do it. What I want is to query one table and show results in two divs on the page. What I mean is that I have some html like this:
<div class="row">
<div class="small">
//
</div>
<div class="large">
//
</div>
<div class="small">
//
</div>
<div class="small">
//
</div>
<div class="small">
//
</div>
<div class="large">
//
</div>
</div>
and the query like this
$stmt = $pdo->prepare("SELECT * FROM cars WHERE cars_cat = ? ORDER BY car_id DESC");
$stmt->execute(array($cat_id));
$data = $stmt->fetchAll();
foreach($data as $row) {
}
The database table is simple table with id, name, image, cars_cat.
UPDATE:
This is the structure of the gallery
<div class="col-sm-4 col-md-4 col-lg-4 nopadding"> <!-- First Column -->
<div class="small">
</div>
<div class="large">
</div>
<div class="small">
</div>
<div class="small">
</div>
</div> <!-- End First Column -->
<div class="col-sm-4 col-md-4 col-lg-4 nopadding"> <!-- Second Column -->
<div class="small">
</div>
<div class="small">
</div>
<div class="large">
</div>
<div class="small">
</div>
</div> <!-- End Second Column -->
<div class="col-sm-4 col-md-4 col-lg-4 nopadding"> <!-- Third Column -->
<div class="large">
</div>
<div class="small">
</div>
<div class="large">
//
</div>
</div> <!-- End Third Column -->
Try this way
<style>
.row {
-webkit-column-width:400px;
-moz-column-width:400px;
column-width:400px;
-webkit-column-gap:5px;
-moz-column-gap:5px;
column-gap:5px;
}
.small-box{
display:inline-block;
margin:0 0 5px 0;
padding:10px;
color:white;
}
.img-responsive{
width:100%;
height:auto;
}
</style>
<div class="row">
<div class="small-box">
<img src="http://aneemals.com/wp-content/uploads/2013/04/photos-of-animals-that-know-what-love-is-3.jpg" alt="img" class="img-responsive">
</div>
<div class="small-box">
<img src="http://www.softstuffcreations.com/refresh/data/zoom_image/1772-PandaBear_resized.jpg" alt="img" class="img-responsive">
</div>
<div class="small-box">
<img src="http://images6.fanpop.com/image/photos/35600000/wild-animals-animals-of-the-world-35665506-800-533.jpg" alt="img" class="img-responsive">
</div>
<div class="small-box">
<img src="http://nice-animals.com/wp-content/uploads/2013/10/facts-of-love-between-animals-08.jpg" alt="img" class="img-responsive">
</div>
<div class="small-box">
<img src="http://www.kenya.com/wp-content/uploads/2013/03/Mt-Kenya-Animals.jpg" alt="img" class="img-responsive">
</div>
<div class="small-box">
<img src="http://www.softstuffcreations.com/refresh/data/zoom_image/1772-PandaBear_resized.jpg" alt="img" class="img-responsive">
</div>
<div class="small-box">
<img src="http://fc09.deviantart.net/fs71/i/2012/364/4/3/animals___lion_9_by_moonsongstock-d5pr9za.jpg" alt="img" class="img-responsive">
</div>
</div>
Means basically what you need to update is to update code this way
<div class="row">
<?php
foreach($data as $row) {
echo '<div class="small-box"> your image </div>';
}
?>
</div>
<div class="row">
<?php
foreach($data as $row) {
if($row->div_type == 0){
echo '<div class="small"> your data </div>';
}else{
echo '<div class="large"> your data </div>';
}
}
?>
</div>

Categories