How to insert accordions when adding tables to database - php

For each table in my database, i need to insert a accordion. So, when I add a table, it should create a accordion with the table name in the accordion's title.
This is my code:
The code that should insert the accordion (.php):
<?php
require 'includes/dbh.inc.php';
$sql = "SELECT count(*) AS TOTALNUMBEROFTABLES FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '4grcbd'";
$result = $conn->query($sql);
foreach ($result as $row) {
$accordion .= '
<h3>' . $row['TOTALNUMBEROFTABLES'] . '</h3>
<div>
<p>
my age is
</p>
</div>';
}
?>
Accordion HTML-Bootstrap:
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
And my connection to database (dbh.inc.php):
$servername = "localhost";
$dBUsername = "root";
$dBPassword = "";
$dBName = "4grcbd";
$conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
if(!$conn) {
die("Connection failed: ".mysqli_connect_error());
}
Thank you for your help!

Related

The image size of last product in my PHP ecommerce website is smaller

I'm writing a PHP ecommerce website by referencing to other PHP ecommerce website (I used same image folder for both websites), however the image of last product is displayed in different size. Can somebody help with this? my website.
The code for my website is here:
<?php
$conn = $pdo->open();
try{
$stmt = $conn->prepare("SELECT * FROM products WHERE category_id = :catid");
$stmt->execute(['catid' => $catid]);
foreach ($stmt as $row) {
$image = (!empty($row['photo'])) ? 'images/'.$row['photo'] : 'images/noimage.jpg';
echo "
<li class='element no_full_width' data-alpha='Curabitur cursus dignis' data-price='20000'>
<ul class='row-container list-unstyled clearfix'>
<li class='row-left'>
<class='container_item'>
<img src='".$image."' class='img-responsive' alt='Curabitur cursus dignis'>
</a>
<div class='hbw'>
<span class='hoverBorderWrapper'></span>
</div>
</li>
<li class='row-right parent-fly animMix'>
<div class='product-content-left'>
<a class='title-5' href='product.php?product=".$row['slug']."'>".$row['name']."></a>
<span class='spr-badge' id='spr_badge_1293239619' data-rating='0.0'>
<span class='spr-starrating spr-badge-starrating'><i class='spr-icon spr-icon-star-empty' style=''></i><i class='spr-icon spr-icon-star-empty' style=''></i><i class='spr-icon spr-icon-star-empty' style=''></i><i class='spr-icon spr-icon-star-empty' style=''></i><i class='spr-icon spr-icon-star-empty' style=''></i></span>
<span class='spr-badge-caption'>
No reviews </span>
</span>
</div>
<div class='product-content-right'>
<div class='product-price'>
<span class='price'>
$".number_format($row['price'], 2)." </span>
</div>
</div>
<div class='list-mode-description'>
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis amet voluptas assumenda est, omnis dolor repellendus quis nostrum. Temporibus autem quibusdam et aut officiis debitis aut rerum dolorem necessitatibus saepe eveniet ut et neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed...
</div>
<div class='hover-appear'>
<form action='#'' method='post'>
<div class='effect-ajax-cart'>
<input name='quantity' value='1' type='hidden'>
<button class='add-to-cart' type='submit' name='add'><i class='fa fa-shopping-cart'></i><span class='list-mode'>Add to Cart</span></button>
</div>
</form>
<div class='product-ajax-qs hidden-xs hidden-sm'>
<div data-href='./ajax/_product-qs.html' data-target='#quick-shop-modal' class='quick_shop' data-toggle='modal'>
<i class='fa fa-eye' title='Quick view'></i><span class='list-mode'>Quick View</span>
</div>
</div>
<a class='wish-list' href='./account.html' title='wish list'><i class='fa fa-heart'></i><span class='list-mode'>Add to Wishlist</span></a>
</div>
</li>
</ul>
</li>
";
}
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
$pdo->close();
?>
This is the website im referencing referenced website
And the code of the referenced website is here:
<?php
$conn = $pdo->open();
try{
$inc = 3;
$stmt = $conn->prepare("SELECT * FROM products WHERE category_id = :catid");
$stmt->execute(['catid' => $catid]);
foreach ($stmt as $row) {
$image = (!empty($row['photo'])) ? 'images/'.$row['photo'] : 'images/noimage.jpg';
$inc = ($inc == 3) ? 1 : $inc + 1;
if($inc == 1) echo "<div class='row'>";
echo "
<div class='col-sm-4'>
<div class='box box-solid'>
<div class='box-body prod-body'>
<img src='".$image."' width='100%' height='230px' class='thumbnail'>
<h5><a href='product.php?product=".$row['slug']."'>".$row['name']."</a></h5>
</div>
<div class='box-footer'>
<b>$ ".number_format($row['price'], 2)."</b>
</div>
</div>
</div>
";
if($inc == 3) echo "</div>";
}
if($inc == 1) echo "<div class='col-sm-4'></div><div class='col-sm-4'></div></div>";
if($inc == 2) echo "<div class='col-sm-4'></div></div>";
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
$pdo->close();
?>

php problem with using a get value. works on one part of the page but not the other

im working on my crud skills, but im having some trouble. the first page shows a list of all blog posts, when the user clicks on read more it sends the specific posts id through the url and is recieved by the destination page which uses that id to display the single post/ heres the code for that part. it actually works fine
function display_single_post($title,$author,$date,$image,$content){
$main_page_blog_html = "<h2>
<a href='#'>%s</a>
</h2>
<p class='lead'>
by <a href='index.php'>%s</a>
</p>
<p><span class='glyphicon glyphicon-time'></span> Posted on %s</p>
<hr>
<img class='img-responsive' src='images/%s'>
<hr>
<p>%s</p>
<hr>
<hr>";
printf("{$main_page_blog_html}",$title,$author,$date,$image,$content);
if(isset($_GET["id"])){
$id = $_GET["id"];
$stmt = $connect->link->query("SELECT * FROM posts WHERE post_id = $id");
while($row = $stmt->fetch()){
$post_title = $row["post_title"];
$post_author = $row["post_author"];
$post_date = date('F j, Y \a\t g:ia', strtotime( $row["post_date"] ));
$post_image = $row["post_image"];
$post_content = $row["post_content"];
$id = $row["post_id"];
display_single_post($post_title,$post_author,$post_date,$post_image,$post_content);
}
}
like i said this all works fine. the get value is recieved and loads the post. the problem is when i try to use that $_get id in a query to insert a comment. all this code is on the one page im just showing the php without the html. anyway heres the code to insert the comment
if(isset($_POST["create_comment"])){
global $connect;
$post_id = $_GET["id"];
$comment_author = $_POST["comment_author"];
$author_email = $_POST["author_email"];
$comment_content = $_POST["comment_content"];
$comment_status = "pending";
edit with all the code
<div class="container">
<div class="row">
<!-- Blog Entries Column -->
<div class="col-md-8">
<h1 class="page-header">
Page Heading
<small>Secondary Text</small>
</h1>
<!-- First Blog Post -->
<?php
$connect = new db();
if(isset($_POST["create_comment"])){
global $connect;
echo "hello";
$post_id = $_GET["id"];
$comment_author = $_POST["comment_author"];
$author_email = $_POST["author_email"];
$comment_content = $_POST["comment_content"];
$comment_status = "pending";
$sql = "INSERT INTO comments(comment_post_id, comment_author, comment_email, comment_content, comment_status)
VALUES(:a,:b,:c,:d,:e)";
$stmt = $connect->link->prepare($sql);
$stmt->bindvalue(":a",$post_id);
$stmt->bindvalue(":b", $comment_author);
$stmt->bindvalue(":c",$author_email);
$stmt->bindvalue(":d",$comment_content);
$stmt->bindvalue(":e",$comment_status);
$stmt->execute();
}
function display_single_post($title,$author,$date,$image,$content){
$main_page_blog_html = "<h2>
<a href='#'>%s</a>
</h2>
<p class='lead'>
by <a href='index.php'>%s</a>
</p>
<p><span class='glyphicon glyphicon-time'></span> Posted on %s</p>
<hr>
<img class='img-responsive' src='images/%s'>
<hr>
<p>%s</p>
<hr>
<hr>";
printf("{$main_page_blog_html}",$title,$author,$date,$image,$content);
}
if(isset($_GET["id"])){
$id = $_GET["id"];
$stmt = $connect->link->query("SELECT * FROM posts WHERE post_id = $id");
while($row = $stmt->fetch()){
$post_title = $row["post_title"];
$post_author = $row["post_author"];
$post_date = date('F j, Y \a\t g:ia', strtotime( $row["post_date"] ));
$post_image = $row["post_image"];
$post_content = $row["post_content"];
$id = $row["post_id"];
display_single_post($post_title,$post_author,$post_date,$post_image,$post_content);
}
}
?>
<hr>
<!-- Blog Comments -->
<!-- Comments Form -->
<div class="well">
<h4>Leave a Comment:</h4>
<form role="form" method="post" action="post.php">
<div class="form-group">
<input type="text" class="form-control" name="comment_author" placeholder="name">
</div>
<div class="form-group">
<input type="email" class="form-control" name="author_email" placeholder="email">
</div>
<div class="form-group">
<textarea class="form-control" rows="3" name="comment_content"></textarea>
</div>
<button type="submit" name="create_comment" class="btn btn-primary">Submit</button>
</form>
</div>
<hr>
<!-- Posted Comments -->
<!-- Comment -->
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/64x64" alt="">
</a>
<div class="media-body">
<h4 class="media-heading">Start Bootstrap
<small>August 25, 2014 at 9:30 PM</small>
</h4>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</div>
<!-- Comment -->
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/64x64" alt="">
</a>
<div class="media-body">
<h4 class="media-heading">Start Bootstrap
<small>August 25, 2014 at 9:30 PM</small>
</h4>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
<!-- Nested Comment -->
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/64x64" alt="">
</a>
<div class="media-body">
<h4 class="media-heading">Nested Start Bootstrap
<small>August 25, 2014 at 9:30 PM</small>
</h4>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</div>
<!-- End Nested Comment -->
</div>
</div>
</div>
Based on your code and your comments, I assume the page is called post.php and when you first reach the page it has the id on the url like this: post.php?id=156.
But once you submit the comments' form, since the action for said form it is simply post.php you're losing the id.
You could add the id on the action after post:
<form role="form" method="post" action="post.php?id=<?php echo $id; ?>">
or add a hidden input with the id:
<input type="hidden" name="id" value="<?php echo $id; ?>">
But then you'd have to reach it with $_POST
Another option is to use the SELF for the action like this:
<form role="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
This will retain the id but also any other get variables you may have on the url.
//EDIT
This is a simplification of the probelm which is working, if you visit post.php?id=456 (or any number) and then press Submit, you get the proper response:
<!-- First Blog Post -->
<?php
if(isset($_POST["create_comment"])){
$post_id = $_GET["id"];
echo "The id is: $post_id";
// gets comment and inserts into the db
}
if(isset($_GET["id"])){
$id = $_GET["id"];
// calls display_single_post
}
?>
<!-- Comments Form -->
<div class="well">
<h4>Leave a Comment:</h4>
<form role="form" method="post" action="post.php?id=<?php echo $id; ?>">
<button type="submit" name="create_comment" class="btn btn-primary">Submit</button>
</form>
</div>

How do I insert data retrieved from database into pre-styled HTML tags?

I want to display the data I retrieve from a database table in styled HTML.
Please look at the code below, the commented out line works and I would like to fill in the data in the <section class="profile"> below the comment.
Thanks in advance
I know my code is vulnerable, but I want to get it to work before I worry about security.
<body>
<div id="wrapper" class="menu">
<?php require('inc-nav.php') ?>
<section class="content">
<?php
require('connect.php');
$conn = mysqli_connect($servername, $username, $password, $dbname);
$sql = "SELECT name, breed, age FROM dogs";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($dogs = mysqli_fetch_assoc($result)) {
// echo 'Name: ' . $dogs['name'] . '<br>' . 'Breed: ' . $dogs['breed'] . '<br>' . 'Age: ' . $dogs['age'] . '<br><hr>';
echo '
<section class="profile">
<figure class="profile-pic"><img src="images/1.jpg" alt=""></figure>
<h1 class="name">Name</h1>
<h2 class="description1">Breed | gender | age</h2>
<p class="description2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto corporis dolores dolorum eaque eum in nemo quos totam ullam. Autem?</p>
<button class="cta-profile">Read more</button>
</section>
';
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
</section>
<?php require('inc-footer.php');?>
</div>
You want like this
<body>
<div id="wrapper" class="menu">
<?php require('inc-nav.php') ?>
<section class="content">
<?php
require('connect.php');
$conn = mysqli_connect($servername, $username, $password, $dbname);
$sql = "SELECT name, breed, age FROM dogs";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($dogs = mysqli_fetch_assoc($result)) {
?>
<section class="profile">
<figure class="profile-pic"><img src="images/1.jpg" alt=""></figure>
<h1 class="name"><?php echo 'Name: ' .$dogs['name']; ?></h1>
<h2 class="description1"> <?php echo 'Breed: ' . $dogs['breed']; ?> | gender | <?phpecho 'Age: ' . $dogs['age']; ?></h2>
<p class="description2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto corporis dolores dolorum eaque eum in nemo quos totam ullam. Autem?</p>
<button class="cta-profile">Read more</button>
</section>
<?php
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
</section>
<?php require('inc-footer.php');?>
</div>
echo '
<section class="profile">
<figure class="profile-pic"><img src="images/1.jpg" alt=""></figure>
<h1 class="name">'.$dogs["name"].'</h1>
<h2 class="description1">'.$dogs["breed"].' | '.$dogs["age"].'</h2>
<p class="description2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto corporis dolores dolorum eaque eum in nemo quos totam ullam. Autem?</p>
<button class="cta-profile">Read more</button>
</section>
';

How do i require user authentication to view dashboard page

On my index page i have my login form for users, then it goes to login.php to handle the login script, from there the users are redirected to dashboardd.php. But i want it to to be so that they have to be logged in to access this page, and not just type in the URL.
Index.php
<?php
session_start();
?>
<?php
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '<ul style="padding:0; color:red;">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="img/favicon.ico">
<title>Jumbotron Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Alec Grogan</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="form" action="login.php" method="POST">
<div class="form-group">
<input type="text" placeholder="Username" name="uname" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" name="pword" class="form-control">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</nav>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div>
<hr>
<footer>
<p>© Company 2014</p>
</footer>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
login.php
<?php
session_start();
$errmsg_arr = array();
$errflag = false;
// configuration
$dbhost = "localhost";
$dbname = "alecgrogan";
$dbuser = "root";
$dbpass = "";
// database connection
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
// new data
$user = $_POST['uname'];
$password = $_POST['pword'];
if($user == '') {
$errmsg_arr[] = 'You must enter your Username';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'You must enter your Password';
$errflag = true;
}
// query
$result = $conn->prepare("SELECT * FROM users WHERE username= :hjhjhjh AND password= :asas");
$result->bindParam(':hjhjhjh', $user);
$result->bindParam(':asas', $password);
$result->execute();
$rows = $result->fetch(PDO::FETCH_NUM);
if($rows > 0) {
header("location: dashboard.php");
}
else{
$errmsg_arr[] = 'Username and Password are not found';
$errflag = true;
}
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
?>
dashboard.php
<?php
echo "string";
?>
Make a $_SESSION e.g. $_SESSION['logged_in'] and fill it with data or set it to true
$username = $_POST['username']; //don't forget to sanitize $_POST values
$userID = (int)$_POST['userID'];
$_SESSION['logged_in'] = array('username' => $username, 'id' => $userID);
OR
$_SESSION['logged_in'] = TRUE;
And then check on the dashboard
if(!isset($_SESSION['logged_in'])){
header('Location:index.php');
}
Now if it does not exists, it will return the user to index.php. Don't forget to use session_start() at the top of every page where you want to call the $_SESSION variables.
You can set an array() in a $_SESSION, so this is ideal for storing user info. Do not store user passwords in a $_SESSION tho.

Query returning only 1 row instent of all

I'm Stuck on below code... Accroding to my understanding below code should display all the rows data which has been created in my database... But im getting only 1 row data in result only one product on my product page... Please help...
<?php
include 'core/database/connect.php';
include 'core/includes/listhead.php';
$dynamiclist = "";
$sql = mysql_query("SELECT * FROM `index` ORDER BY price1 LIMIT 2");
$hotelcount = mysql_num_rows($sql);
if($hotelcount > 0) {
while($row = mysql_fetch_array($sql)) {
$id = $row['index_id'];
$pic = $row['main_pic'];
$country = $row['country1'];
$destination = $row['destination1'];
$price = $row["price1"];
$dynamiclist = '<div class=/"offset-2/">
<div class="col-md-4 offset-0">
<div class="listitem2">
<img src="'. $pic .'" alt=""/>
<div class="liover"></div>
<a class="fav-icon" href="#"></a>
<a class="book-icon" href="details.html"></a>
</div>
</div>
<div class="col-md-8 offset-0">
<div class="itemlabel3">
<div class="labelright">
<img src="images/filter-rating-5.png" width="60" alt=""/><br/><br/><br/>
<img src="images/user-rating-5.png" width="60" alt=""/><br/>
<span class="size11 grey">18 Reviews</span><br/><br/>
<span class="green size18"><b>'. $price .'</b></span><br/>
<span class="size11 grey">Avg/Night</span><br/><br/><br/>
<form action="http://demo.titanicthemes.com/travel/details.html">
<button class="bookbtn mt1" type="submit">Book</button>
</form>
</div>
<div class="labelleft2">
<b>'. $country .'</b><br/><br/><br/>
<p class="grey">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec semper lectus. Suspendisse placerat enim mauris, eget lobortis nisi egestas et.
Donec elementum metus et mi aliquam eleifend. Suspendisse volutpat egestas rhoncus.</p><br/>
<ul class="hotelpreferences">
<li class="icohp-internet"></li>
<li class="icohp-air"></li>
<li class="icohp-pool"></li>
<li class="icohp-childcare"></li>
<li class="icohp-fitness"></li>
<li class="icohp-breakfast"></li>
<li class="icohp-parking"></li>
<li class="icohp-pets"></li>
<li class="icohp-spa"></li>
</ul>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="offset-2"><hr class="featurette-divider3"></div>';
}
} else {
$dynamiclist = 'We Do Not Have Any Hotel Listed in This City';
}
?>
<?php echo $dynamiclist ?>
<?php include 'core/includes/listfooter.php'; ?>
You have two issues
Your database query is limited to 2 items (although that doesn't explain the 1 item problem you have at the moment)
removing LIMIT 2 will fix this
Secondly
$dynamiclist = '<div class=/"offset-2/">
the "=" sign means that you set it as the content each time.
This is fine except you echo it OUTSIDE your while loop
either echo it within your while loop or change it to
$dynamiclist .= '<div class=/"offset-2/">
notice the .= -> that Adds items to the end of the string.
Hope that helps
Change the
$dynamiclist = '<div class=/"offset-2/">
to
$dynamiclist .= '<div class=/"offset-2/">
If you want to load all rows, remove 'LIMIT' from your query.

Categories