i have created a php page in which i want that whenever i refresh the page it should shuffle and in that data i want that whenever i click on data it should redirect to a new page where that data should be displayed for this I have used Session to store it.
home.php
<?php
$con = new mysqli("localhost","root","","writersplanet");
$sql = "SELECT * FROM books ORDER BY RAND()";
$execute = mysqli_query($con,$sql);
while ($row = mysqli_fetch_assoc($execute)) {
$_SESSION['uploadcoverimg'] = $row['uploadcoverimg'];
$_SESSION['bookname'] =$row['bookname'];
$_SESSION['uname'] =$row['uname'];
$_SESSION['summary'] =$row['summary'];
$_SESSION['thoughts'] =$row['thoughts'];
$_SESSION['pdf'] = $row['pdf'];
$_SESSION['date'] = $row['date'];
echo "<div class='container' align='center'>
<a href='readbook.php'>
<div class='box'>
<div class='imgbox'>
<img src='upload/".$row['uploadcoverimg']."'>
</div>
<div class='content'>
<h3>".$row['bookname']." <i class='fas fa-chevron-circle-right'></i>".$row['uname']."</h3>
<p>".$row['summary']."</p>
</div>
</div>
</a>
<div class='outcome'>
<div class='heart'>
<i class='fas fa-heart'></i>
</div>
<div class='eye'>
<i class='fas fa-eye'></i>
</div>
<div class='ratings'>
<i class='fas fa-star-half-alt'></i>
</div>
</div>
<div class='scrollmenu1'>
<a href='#home' style='border-radius: 10px;margin-top: 10px; background-color: black;color: white; width: 65px;height: 30px;box-sizing: border-box;'>Horror</a>
<a href='#news' style='border-radius: 10px;margin-top: 10px; width: 65px;height: 30px;box-sizing: border-box; background-color: #0a3da3;color: white;'>Sci-Fi</a>
<a href='#contact' style='border-radius: 10px;margin-top: 10px; background-color: #ff69b4;color: white; width: 65px;height: 30px;box-sizing: border-box;'>Love</a>
</div>
<div class='content1'>
<h2>Time</h2>
<p><br>
Writers Thoughts about this book:
".$row['thoughts']."
</p>
</div>
</div>";
}
?>
In my sql code I have used [id, uname, bookname, summary,thoughts,uploadcoverimg,pdf,date].
readbook.php
<img class='bookcover' src='Desert.jpg'>
<div class='heading'>
<h3><?php echo $_SESSION['bookname']; ?> <i class='fas fa-chevron-circle-right'></i><?php echo $_SESSION['uname'];?></h3>
</div>
<div class='container'>
<div class="half_star">
<i id='half_star' class='fas fa-star-half-alt'></i>
</div>
<div class="comment">
<i id='comment' class='fas fa-comments'></i>
</div>
<div class="like">
<i id='like' class='fas fa-thumbs-up'></i><br>
</div>
<div class="date">
<i id='date' class='fas fa-calendar-alt'></i><br>
<?php echo $_SESSION['date'];?>
</div>
<div class="share">
<i id='share' class='fas fa-share'></i>
</div>
<div class='scrollmenu1'>
<a class='horror' href='#home' color='white'>Horror</a>
<a class='sci-fi' href='#news'>Sci-Fi</a>
<a class='love' href='#contact'>Love</a>
</div>
</div>
<div class='summary'>
<h1>Summary of the Book</h1>
<p><?php echo $_SESSION['summary'];?></p>
</div>
<div class="thoughts2">
<h2 class="quotes_head">Thoughts of the Writer</h2>
<p><?php echo $_SESSION['thoughts'];?></p>
</div>
<div class="storyhead">
<h1>Let's start the story:</h1>
</div>
<div class="taskbar">
<button class="bookmark"><i id="bookmark" class="fas fa-bookmark"></i>Bookmark</button>
<button class="unlock"><i id="unlock" class="fas fa-unlock"></i>Unlock</button>
<button class="download">Download</button>
</div>
<div class="pages">
click here!
<iframe src="upload/<?php echo $_SESSION['pdf'];?>" width="1000px" height="500px"></iframe>
</div>
If anybody can help me then its a great thank you from my side because this is related to my career planning.
Thank You
Use this function:
https://www.php.net/manual/en/function.http-build-query.php
instead of this:
$_SESSION['uploadcoverimg'] = $row['uploadcoverimg'];
$_SESSION['bookname'] =$row['bookname'];
$_SESSION['uname'] =$row['uname'];
$_SESSION['summary'] =$row['summary'];
$_SESSION['thoughts'] =$row['thoughts'];
$_SESSION['pdf'] = $row['pdf'];
$_SESSION['date'] = $row['date'];
use this:
$query_string = http_build_query($row);
change a href url so you append '?$query_string' to the URL
<a href='readbook.php?<?php echo $query_string?>'>
and in your readbook.php use $_GET[] instead of $_SESSION[];
There are some limitation on how long a query string can be, but in your case, I think you have small enough dataset to pass.
Your solution done properly would be using a MySQL connection in the readbook.php while you would pass only a book id from the previous page so that you can select info for the exact book from the database using a query with where clause (i.e. select * from books where book_id = x).
Related
This question already has answers here:
Bootstrap 3 - style a site with 3 columns per row on medium & large devices and two columns on small
(2 answers)
Closed 2 years ago.
I am trying to display cards but in this way, all three cards are showing the same information whereas I want every card to show specific entries in the database like 1st one the first entry and second one the second then the third one the third then change line and restart to display 4,5,6 entry and so on. Can anyone please help?
include_once('db/connection.php');
$query="select * from news ORDER BY id DESC";
$result=mysqli_query($conn,$query);
?>
<?php
while($rows=mysqli_fetch_array($result))
{
$cc =$rows['category2'];
?>
<div>
<div class="container">
<div class="cust_bloglistintro">
<div class="row">
<div class="col-md-6 col-lg-4 cust_blogteaser" style="padding-bottom: 20px;margin-bottom: 32px;height: 750px;">
<div class="card" data-aos="fade-up" style="height: 700px;"><img class="card-img-top w-100 d-block" src="images/<?php echo $rows['thumbnail'];?>">
<div class="card-body">
<h4 class="card-title"><?php echo $rows['title']; ?></h4><span style="font-family: 'Open Sans', sans-serif;font-size: 12px;margin-bottom: 5px;"><?php echo $rows['3']; ?></span>
<p class="card-text"><?php echo substr($rows['2'],0,400); ?></p><?php if($cc=="bigbites"){?><a class="card-link" href="bigbites.php?ii=<?php echo $rows['0']?>>" target="_top">Read more...</a><?php } else{?><a class="card-link" href="<?php echo $rows['7']; ?>" target="_top">Read more...</a><?php }?>
</div>
<div class="text-center" style="bottom: 10px;"><i class="fab fa-whatsapp-square" id="whatsapp"></i><i class="fab fa-facebook-square" id="facebook"></i><i class="fab fa-linkedin" id="linkedin"></i><a href="extra.php?ii=<?php echo $rows['0']?>"><i class="fas fa-share" id="share"></i></div>
</div>
</div>
<div class="col-md-6 col-lg-4 cust_blogteaser" style="padding-bottom: 20px;margin-bottom: 32px;height: 750px;">
<div class="card" data-aos="fade-up" style="height: 700px;"><img class="card-img-top w-100 d-block" src="images/<?php echo $rows['thumbnail'];?>">
<div class="card-body">
<h4 class="card-title"><?php echo $rows['title']; ?></h4><span style="font-family: 'Open Sans', sans-serif;font-size: 12px;margin-bottom: 5px;"><?php echo $rows['3']; ?></span>
<p class="card-text"><?php echo substr($rows['2'],0,400); ?></p><?php if($cc=="bigbites"){?><a class="card-link" href="bigbites.php?ii=<?php echo $rows['0']?>>" target="_top">Read more...</a><?php } else{?><a class="card-link" href="<?php echo $rows['7']; ?>" target="_top">Read more...</a><?php }?>
</div>
<div class="text-center" style="bottom: 10px;"><i class="fab fa-whatsapp-square" id="whatsapp"></i><i class="fab fa-facebook-square" id="facebook"></i><i class="fab fa-linkedin" id="linkedin"></i><a href="extra.php?ii=<?php echo $rows['0']?>"><i class="fas fa-share" id="share"></i></div>
</div>
</div>
<div class="col-md-6 col-lg-4 cust_blogteaser" style="padding-bottom: 20px;margin-bottom: 32px;height: 750px;">
<div class="card" data-aos="fade-up" style="height: 700px;"><img class="card-img-top w-100 d-block" src="images/<?php echo $rows['5'];?>">
<div class="card-body">
<h4 class="card-title"><?php echo $rows['1']; ?></h4><span style="font-family: 'Open Sans', sans-serif;font-size: 12px;margin-bottom: 5px;"><?php echo $rows['3']; ?></span>
<p class="card-text"><?php echo substr($rows['2'],0,400); ?></p><?php if($cc=="bigbites"){?><a class="card-link" href="bigbites.php?ii=<?php echo $rows['0']?>>" target="_top">Read more...</a><?php } else{?><a class="card-link" href="<?php echo $rows['7']; ?>" target="_top">Read more...</a><?php }?>
</div>
<div class="text-center" style="bottom: 10px;"><i class="fab fa-whatsapp-square" id="whatsapp"></i><i class="fab fa-facebook-square" id="facebook"></i><i class="fab fa-linkedin" id="linkedin"></i><a href="extra.php?ii=<?php echo $rows['0']?>"><i class="fas fa-share" id="share"></i></div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
Many ways of doing this, but I've used this approach recently...
<?php
$resultCount=0;
if(mysqli_num_rows($result) >0)
{
?>
<div>
<div class="container">
<div class="cust_bloglistintro">
<div class="row">
<?php
while($rows=mysqli_fetch_array($result))
{
$cc =$rows['category2'];
?>
<div class="col-md-6 col-lg-4 cust_blogteaser" style="padding-bottom: 20px;margin-bottom: 32px;height: 750px;">
<div class="card" data-aos="fade-up" style="height: 700px;"><img class="card-img-top w-100 d-block" src="images/<?php echo $rows['thumbnail'];?>">
<div class="card-body">
<h4 class="card-title"><?php echo $rows['title']; ?></h4><span style="font-family: 'Open Sans', sans-serif;font-size: 12px;margin-bottom: 5px;"><?php echo $rows['3']; ?></span>
<p class="card-text"><?php echo substr($rows['2'],0,400); ?></p><?php if($cc=="bigbites"){?><a class="card-link" href="bigbites.php?ii=<?php echo $rows['0']?>>" target="_top">Read more...</a><?php } else{?><a class="card-link" href="<?php echo $rows['7']; ?>" target="_top">Read more...</a><?php }?>
</div>
<div class="text-center" style="bottom: 10px;"><i class="fab fa-whatsapp-square" id="whatsapp"></i><i class="fab fa-facebook-square" id="facebook"></i><i class="fab fa-linkedin" id="linkedin"></i><a href="extra.php?ii=<?php echo $rows['0']?>"><i class="fas fa-share" id="share"></i></div>
</div>
</div>
<?php
$resultCount++;
if ($resultCount % 3 == 0) // start new row
{
?>
</div>
<div class="row">
<?php
}
}
if ($resultCount % 3 != 0) // if we didn't just end a row in the loop, end it now
{
?>
</div>
<?php
}
// now close divs
?>
</div>
</div>
</div>
<?php
} // end of if num_rows>0
?>
i want to include a else statement after the completion of the block after the second if for category equal to helathcare ....now i want another else for finance but i am not getting where excatly to place that else
i have a confusion on where to keep the else for finance and 2 more categories
now whenever i try to place the one else at the last goes unrecable to its if statement i donno its very confusing as to where to place 2 more else if statments for 2 more categories
<?php
global $row2;
if(isset($_POST['category']))
{
if($_POST['category']== 'Healthcare')
{
$query = "select *from event where category = 'Healthcare';";
$result=mysqli_query($conn,$query)or die(mysqli_error($conn));
while($row2= mysqli_fetch_array($result))
{
?>
<div class="events events-full event-list">
<div class="container">
<div class="row">
<div class="col-md-9 col-sm-8">
<!--Blog Post Start-->
<div class="blog-post">
<div class="post-thumb">
<div class="link-wrap"> <i class="fa fa-search"></i> <i class="fa fa-link"></i> </div>
<img src="images/gallery/<?php echo $row2['event_image']?>" alt='user'></div>
<div class="event-text">
<div class="event-counter"></div>
<h4> <?php echo($row2['title']); ?> </h4>
<p><?php echo($row2['descrption']); ?></p>
<p><span class="glyphicon glyphicon-map-marker"><?php echo($row2['location']); ?></span></p>
<p><span class="glyphicon glyphicon-grain"><?php echo($row2['organizer']); ?></span></p>
<a class="nd" href="">
<form action="eventdetail.php" method="post">
<input type='hidden' value="<?php echo $row2['id']; ?>" name='id'/>
<button type="submit" class="btn btn-primary" name="detail" value=”detail”>Event Detail</button>
</div>
</a> </div>
</div>
</form>
<!--Blog Post End-->
<?php }
}
}
else
{
global $row2;
$query = "select *from event;" ;
$result=mysqli_query($conn,$query)or die(mysqli_error($conn));
while($row2= mysqli_fetch_array($result))
{
?>
<div class="events events-full event-list">
<div class="container">
<div class="row">
<div class="col-md-9 col-sm-8">
<!--Blog Post Start-->
<div class="blog-post">
<div class="post-thumb">
<div class="link-wrap"> <i class="fa fa-search"></i> <i class="fa fa-link"></i> </div>
<img src="images/gallery/<?php echo $row2['event_image']?>" alt='user'></div>
<div class="event-text">
<div class="event-counter"></div>
<h4> <?php echo($row2['title']); ?> </h4>
<p><?php echo($row2['descrption']); ?></p>
<p><span class="glyphicon glyphicon-map-marker"><?php echo($row2['location']); ?></span></p>
<p><span class="glyphicon glyphicon-grain"><?php echo($row2['organizer']); ?></span></p>
<a class="nd" href="">
<form action="eventdetail.php" method="post">
<input type='hidden' value="<?php echo $row2['id']; ?>" name='id'/>
<button type="submit" class="btn btn-primary" name="detail" value=”detail”>Event Detail</button>
</div>
</a> </div>
</div>
</form>
<!--Blog Post End-->
<?php } } ?>
?>
You can't put multiple else blocks along with the if block. However, you can use multiple(as many as you want) elseif/else if blocks along with the if block, like this:
if($_POST['category'] == 'Healthcare'){
...
}elseif($_POST['category'] == 'Finance'){
...
}elseif($_POST['category'] == '...'){
...
}else{
...
}
Here's the reference: http://php.net/manual/en/control-structures.elseif.php
Part of your problem seems to be poor formatting. If you lined up your open and close tags for your if statements I think you would be able to see this better. Having said that, you can add any elseif/if clauses for the category if where I marked below:
<!--Blog Post End-->
<?php
} // closes while loop
} else{ } // closes healthcare if, add extra else here
} // closes POST if
else
{
I am working on a project where I came across where when I click plus sign the data will hide and the appear in the div next to it.
here is the code:
<fieldset class="col-md-4" >
<legend>Services</legend>
<div class="col-md-12" >
<?php
$id = 0;
foreach ($servicesname as $val) {
$id++;
?>
<div class="col-md-12" style="font-size: 16px;" id="itemservices<?php echo $id ?>">
<span style="float:left;" ><?php echo $val[0]['servicename']; ?></span>
<a style="float:right;" href onclick="return addSrvToCart('itemservices<?php echo $id ?>')" >
<strong>₹ <?php echo $val[0]['amount']; ?></strong>
<span class="glyphicon glyphicon-plus-sign" id="id_<?php echo $id; ?>"></span>
</a>
</div>
<?php } ?>
</div>
</fieldset>
and the code for next div:
<fieldset class="col-md-4" >
<legend>Cart</legend>
<div style="list-style:none;" class="no-left-padding" id="cart">
<div class="col-md-12" >
</div>
</div>
<div class="col-sm-12 no-right-padding" style="background-color:#f3f0f0; padding-top:6px; border:1px solid#ccc">
<label class="pull-right">/*what should i write here to show the sum */: ₨ </label>
</div>
<button style="margin-top:10px;" class="btn btn-primary btn-sm pull-right" onclick="bookNowAfterFilter()">Book Now</button>
</fieldset>
And This the Jquery code:
<script>
function addSrvToCart(elem){
alert($('#' + elem).html());
$('#' + elem).hide();
//return false;
//what should i write here the show that hidden div
document.getElementById('summery);
return false;
}
</script>
This is the picture and I want to display the data in the Cart div and show the amount
You need to change in both HTML and Script to achieve the result
Try like this
HTML
<fieldset class="col-md-4" >
<legend>Services</legend>
<div class="col-md-12" >
<?php
$id = 0;
foreach ($servicesname as $val) {
$id++;
?>
<div class="col-md-12" style="font-size: 16px;" id="itemservices<?php echo $id ?>">
<span style="float:left;" ><?php echo $val[0]['servicename']; ?></span>
<a style="float:right;" onclick=" addSrvToCart('itemservices<?php echo $id ?>')" >
₹<strong> <?php echo $val[0]['amount']; ?></strong>
<span class="glyphicon glyphicon-plus-sign" id="id_<?php echo $id; ?>"></span>
</a>
</div>
<?php } ?>
</div>
</fieldset>
and the code for next div:
<fieldset class="col-md-4" >
<legend>Cart</legend>
<div style="list-style:none;" class="no-left-padding">
<div class="col-md-12" id="cart" >
</div>
</div>
<div class="col-sm-12 no-right-padding pull-right" style="background-color:#f3f0f0; padding-top:6px; border:1px solid#ccc">
Total: ₨ <label class="" id="sumAmount">0</label>
</div>
<button style="margin-top:10px;" class="btn btn-primary btn-sm pull-right" onclick="bookNowAfterFilter()">Book Now</button>
</fieldset>
Script:
function addSrvToCart(elem){
var div=$('#' + elem);
div.hide();
$('#cart').append(div.html());
var total = parseInt(div.find('strong').html()) + parseInt($('#sumAmount').html());
$('#sumAmount').html(total);
}
It will produce output as
I think it will help you.
I have a dynamic gallery, where its looping.
but my gallery thumbs are messed up.
I used clearfix and it worked,but i press ctrl z and it didnt work ctrl y.
So i lost where it was my mistake with clear fix.
So now my row is not going by side i mean...
my thumbs its not starting from the left to right.
it starts in the left and its ending on the buttom of the page in a row down.
here is a pic of it.
here is my code:
<div class="container">
<?php
$sql = "SELECT * FROM gallery ORDER BY id DESC LIMIT $start_from, $per_page";
$run = mysqli_query($conn,$sql);
while ($rows = mysqli_fetch_assoc($run))
{
echo'
<div class="row">
<div class="col-md-3 col-sm-2 ">
<div class="thumbnail " id="real-estates-columns">
<div class="text-center">'.($rows['image'] == '' ? 'No Image' : '<img src="../'.$rows['image'].'" width="100%" >').'</div>
<span class="label label-danger info pull-right">
<span data-toggle="tooltip" title="viewed"><b class="glyphicon glyphicon-filter"></b></span>
<span data-toggle="tooltip" title="category">'.ucfirst($rows['category']).' </span>
</span>
<div class="title-realestates-columns caption">
<h3><a><strong>'.$rows['title'].'</strong></a></h3>
<!--p>'.substr($rows['description'],0,30).'...</p--->
<div class="row">
<button type="button" class="btn btn-danger btn-block" data-toggle="modal" data-target="#info'.$rows['id'].'" ><span class="glyphicon glyphicon-info-sign"></span> Info</button>
</div>
</div>
</div>
</br>
</div>
</div>
';
}
?>
</div>
If i take out my div class="row" out of my loop and the closing div of my class row too,the gallery works like this...
How can i fix this?
the thing is clearfix but were.
You need to add clearfix after each 4th col
<?php
if ($i%4 == 0){ ?>
<div class="clearfix"></div>
<?php } ?>
Full code:
<div class="container">
<?php
$sql = "SELECT * FROM gallery ORDER BY id DESC LIMIT $start_from, $per_page";
$run = mysqli_query($conn,$sql);
$i = 1;
while ($rows = mysqli_fetch_assoc($run))
{
echo'
<div class="row">
<div class="col-md-3 col-sm-2 ">
<div class="thumbnail " id="real-estates-columns">
<div class="text-center">'.($rows['image'] == '' ? 'No Image' : '<img src="../'.$rows['image'].'" width="100%" >').'</div>
<span class="label label-danger info pull-right">
<span data-toggle="tooltip" title="viewed"><b class="glyphicon glyphicon-filter"></b></span>
<span data-toggle="tooltip" title="category">'.ucfirst($rows['category']).' </span>
</span>
<div class="title-realestates-columns caption">
<h3><a><strong>'.$rows['title'].'</strong></a></h3>
<!--p>'.substr($rows['description'],0,30).'...</p--->
<div class="row">
<button type="button" class="btn btn-danger btn-block" data-toggle="modal" data-target="#info'.$rows['id'].'" ><span class="glyphicon glyphicon-info-sign"></span> Info</button>
</div>
</div>
</div>
</br>
</div>';
if ($i%4 == 0){ ?>
<div class="clearfix"></div>
<?php }
echo'
</div>
';
$i++;
}?>
</div>
I found a solution for my rows
I found in this link http://www.bluthemes.com/blog/3/clearing-bootstrap-3-columns
This is the css that fixed everything.
/* Bootstrap Clearfix */
/* Tablet */
#media (min-width:767px){
/* Column clear fix */
.col-lg-1:nth-child(12n+1),
.col-lg-2:nth-child(6n+1),
.col-lg-3:nth-child(4n+1),
.col-lg-4:nth-child(3n+1),
.col-lg-6:nth-child(2n+1),
.col-md-1:nth-child(12n+1),
.col-md-2:nth-child(6n+1),
.col-md-3:nth-child(4n+1),
.col-md-4:nth-child(3n+1),
.col-md-6:nth-child(2n+1){
clear: none;
}
.col-sm-1:nth-child(12n+1),
.col-sm-2:nth-child(6n+1),
.col-sm-3:nth-child(4n+1),
.col-sm-4:nth-child(3n+1),
.col-sm-6:nth-child(2n+1){
clear: left;
}
}
/* Medium Desktop */
#media (min-width:992px){
/* Column clear fix */
.col-lg-1:nth-child(12n+1),
.col-lg-2:nth-child(6n+1),
.col-lg-3:nth-child(4n+1),
.col-lg-4:nth-child(3n+1),
.col-lg-6:nth-child(2n+1),
.col-sm-1:nth-child(12n+1),
.col-sm-2:nth-child(6n+1),
.col-sm-3:nth-child(4n+1),
.col-sm-4:nth-child(3n+1),
.col-sm-6:nth-child(2n+1){
clear: none;
}
.col-md-1:nth-child(12n+1),
.col-md-2:nth-child(6n+1),
.col-md-3:nth-child(4n+1),
.col-md-4:nth-child(3n+1),
.col-md-6:nth-child(2n+1){
clear: left;
}
}
/* Large Desktop */
#media (min-width:1200px){
/* Column clear fix */
.col-md-1:nth-child(12n+1),
.col-md-2:nth-child(6n+1),
.col-md-3:nth-child(4n+1),
.col-md-4:nth-child(3n+1),
.col-md-6:nth-child(2n+1),
.col-sm-1:nth-child(12n+1),
.col-sm-2:nth-child(6n+1),
.col-sm-3:nth-child(4n+1),
.col-sm-4:nth-child(3n+1),
.col-sm-6:nth-child(2n+1){
clear: none;
}
.col-lg-1:nth-child(12n+1),
.col-lg-2:nth-child(6n+1),
.col-lg-3:nth-child(4n+1),
.col-lg-4:nth-child(3n+1),
.col-lg-6:nth-child(2n+1){
clear: left;
}
}
I have this code snippet that is failing to work, don't know what am doing wrong, am getting content from MYSQL database and using if else statement with while loop to echo the contents.
<?php
if ($row_item['cat_item_id'] == ''){
echo '<div class="col-sm-6 col-md-3"">
</p>
<p>
No Item To Show
</p>
</div>
</div>';
}
else {
while ($row_item = mysql_fetch_assoc($item)){
echo
'
<div class="col-sm-6 col-md-3" style="'.$row_item['display'].'">
<div class="thumbnail">
<img src="myaccount/user_data/'.$row_item['file_name'].'" />
</div>
<div class="caption">
<h3>'.$row_item['item_name'].'</h3>
<p>
<a href="item_detail.php?item='.$row_item['cat_item_id'].'" class="btn btn-primary" role="button">
View Item
</a>
<a href="contact_seller.php?contact='.$row_item['cat_item_id'].'" class="btn btn-default" role="button">
Contact Owner
</a>
</p>
</div>
</div>';
}
}
?>
Help me figure out what am not doing right.
You have to call while ($row_item = mysql_fetch_assoc($item))
first place.
Otherwise the $row_items doesn't get initialized properly.
So you put all inside
while ($row_item = mysql_fetch_assoc($item))
And check for the if-else conditions inside the while:
if ($row_item['cat_item_id'] == '') // this goes inside the while. Otherwise $row_item is not initialized properly
You are checking if
if ($row_item['cat_item_id'] == ''){
before you actually call
while ($row_item = mysql_fetch_assoc($item)){
To get $row_item
Try changing it to something like this:
while ($row_item = mysql_fetch_assoc($item)){
if ($row_item['cat_item_id'] == ''){
echo '<div class="col-sm-6 col-md-3"">
</p>
<p>No Item To Show</p></div></div>';
}else {
echo
'
<div class="col-sm-6 col-md-3" style="'.$row_item['display'].'">
<div class="thumbnail">
<img src="myaccount/user_data/'.$row_item['file_name'].'" />
</div>
<div class="caption">
<h3>'.$row_item['item_name'].'</h3>
<p>
<a href="item_detail.php?item='.$row_item['cat_item_id'].'" class="btn btn-primary" role="button">
View Item
</a>
<a href="contact_seller.php?contact='.$row_item['cat_item_id'].'" class="btn btn-default" role="button">
Contact Owner
</a>
</p>
</div>
</div>';
}
}
Try mysql_fetch_array
while ($row_item = mysql_fetch_array($item)){
echo
'
<div class="col-sm-6 col-md-3" style="'.$row_item['display'].'">
<div class="thumbnail">
<img src="myaccount/user_data/'.$row_item['file_name'].'" />
</div>
<div class="caption">
<h3>'.$row_item['item_name'].'</h3>
<p>
<a href="item_detail.php?item='.$row_item['cat_item_id'].'" class="btn btn-primary" role="button">
View Item
</a>
<a href="contact_seller.php?contact='.$row_item['cat_item_id'].'" class="btn btn-default" role="button">
Contact Owner
</a>
</p>
</div>
</div>';
}