I want to limit my articles to 3 per page ... the page has appeared but the article is still on one page .
require_once 'koneksi.php';
$result = mysqli_query($koneksi, "SELECT * FROM tbl_artikel");
$aktif = 'artikel';
$halaman = 3;
$page = isset($_GET["halaman"]) ? (int)$_GET["halaman"] : 1;
$mulai = ($page>1) ? ($page * $halaman) - $halaman : 0;
$total = mysqli_num_rows($result);
$pages = ceil($total/$halaman);
$query = "SELECT * FROM tbl_artikel LIMIT $mulai, $halaman";
$result2 = mysqli_query($koneksi, $query);
$no =$mulai+1;
?>
and here is the code for article
<?php while($artikel = mysqli_fetch_assoc($result)) : ?>
<div class="artikel">
<div class="info">
<div class="post mb-2">
<span class="tgl"><?= date('d M y', strtotime($artikel['tanggal'])) ?></span>
<span class="judul"><?= $artikel['judul'] ?></span>
</div>
</div>
<div class="detail">
<div class="clearfix" style="text-align: justify;">
<img src="images/artikel/<?= $artikel['foto'] ?>" alt="" width="200px" class="float-left mr-2">
<?= substr($artikel['isi'], 0, 150) . '...' ?>
</div>
Related
We are trying to filter based on the tags or the dropdown menu, we are trying to create a blog website that has tags and those tags can be used to filter the posted content on the homepage Tags dropdown menu:. Here should be the content in the page: Here should be the content in the page:
<nav>
<ul>
<li>Home</li>
<li>Tags<i class="material-icons">arrow_drop_down</i>
<ul class = "dropdown">
<li>All</button></li>
<li>Homemade</button></li>
<li>Pro</button></li>
<li>Resto</button></li>
</ul>
</li>
<!-- Posting -->
<div>
<?php
$query = "select * from posts order by date limit 8";
$result = mysqli_query($con,$query,$tagHomemade);
?>
<?php if(mysqli_num_rows($result) > 0):?>
<div>
<?php while ($row = mysqli_fetch_assoc($result)):?>
<?php
$user_id = $row['user_id'];
$query = "select username, image from users where id ='$user_id' limit 1";
$res = mysqli_query($con,$query);
$user_row = mysqli_fetch_assoc($res);
?>
<div class="card">
<div style ="display: flex;">
<div style ="flex:1", >
<div class="profile"><img class ="icon" src="<?=$user_row['image']?>"></div>
</div>
<div style ="flex:2;" >
<h5>Posted by: <?php echo $_SESSION['logged']['username']?>,
<?php echo date("jS M, Y",strtotime($row['date']))?>
</h5>
<h3><?php echo $row['tag']?>: <?php echo $row['title']?></h>
</div>
</div>
<div>
<?php if (file_exists($row['image']))?>
<div class="img" style="text-align:center;">
<img class="postPic" src="<?=$row['image']?>">
</div>
</div>
<div>
<?php if (!empty ($POST['post']));?>
<?php echo $row['post']?>
</div>
</div>
<?php endwhile;?>
</div>
</div>
<?php endif;?>`
</div>
Set tags in the url like this:
<li>Homemade</button></li>
Then you can get it by $_GET['tag'] in your code. Then put it on the SQL query.
Good to know: It's strongly recommended to use prepared statements and don't use $_GET['tag'] directly in your SQL code. It prevents SQL injection and cares about special characters as well.
Update:
<nav>
<ul>
<li>Home</li>
<li>Tags<i class="material-icons">arrow_drop_down</i>
<ul class = "dropdown">
<li>All</button></li>
<li>Homemade</button></li>
<li>Pro</button></li>
<li>Resto</button></li>
</ul>
</li>
<!-- Posting -->
<div>
<?php
$where = !empty($_GET['tag']) ? "where tag = '" . $_GET['tag'] . "'" : "";
$query = "select * from posts $where order by date limit 8";
$result = mysqli_query($con,$query);
?>
<?php if(mysqli_num_rows($result) > 0):?>
<div>
<?php while ($row = mysqli_fetch_assoc($result)):?>
<?php
$user_id = $row['user_id'];
$query = "select username, image from users where id ='$user_id' limit 1";
$res = mysqli_query($con,$query);
$user_row = mysqli_fetch_assoc($res);
?>
<div class="card">
<div style ="display: flex;">
<div style ="flex:1", >
<div class="profile"><img class ="icon" src="<?=$user_row['image']?>"></div>
</div>
<div style ="flex:2;" >
<h5>Posted by: <?php echo $_SESSION['logged']['username']?>,
<?php echo date("jS M, Y",strtotime($row['date']))?>
</h5>
<h3><?php echo $row['tag']?>: <?php echo $row['title']?></h>
</div>
</div>
<div>
<?php if (file_exists($row['image']))?>
<div class="img" style="text-align:center;">
<img class="postPic" src="<?=$row['image']?>">
</div>
</div>
<div>
<?php if (!empty ($POST['post']));?>
<?php echo $row['post']?>
</div>
</div>
<?php endwhile;?>
</div>
</div>
<?php endif;?>
</div>
I have a page which allows you to filter results using an AJAX call which works fine, I have added pagination which work fine initially but as soon as you move to another page, the checkbox becomes unchecked and it just shows all results again. I assume this is because the page is reloading when it moves to page 2, is there a way of keep the filter setting set and continue to show the results from the filter AJAX. The pagination obvisouly works fine when no filter is selected but my brain just doesn't seem to be working and can't work this out.
Any help would be appreciated!
My code is below, I am also aware that currently my code is open to sql injection but just trying to get everything to work and then will go back through it:
<body>
<?php include("PHP/header.php"); ?>
<div class="container-fluid">
<div class="container" style="margin-top: 2%; text-align: center;">
<h1> Reviews</h1>
On This page you will find our reviews on music tech and software
<br/>
<br/>
<br/>
Filter Reviews:
<ul class="list-group">
<?php
$search = $conn->prepare("SELECT DISTINCT reviewcat FROM review_db ORDER BY reviewcat");
$search->execute();
while ($row = $search->fetch(PDO::FETCH_ASSOC)) {
?>
<li class="list-group-item">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input product_check" value="<?=$row['reviewcat'];?>" id="reviewcat"> <?=$row['reviewcat']; ?>
</label>
</div>
</li>
<?php } ?>
</ul>
</div>
<br/><br/>
<div class="row-fluid ">
<h5 class="text-center" id="textChange"> All Reviews </h5>
<hr>
<div class="text-center">
<img src="Images/loader.gif" id="loader" width="100" style="display: none">
</div>
<?php
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
// Prev + Next
$prev = $pageno - 1;
$next = $pageno + 1;
?>
<div id="result" class="card-deck card_group_style pt-4" >
<?php
$stmt = $conn->prepare("SELECT COUNT(*) FROM review_db");
$stmt->execute();
$total_rows = $stmt->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$result = $conn->prepare("SELECT * FROM review_db ORDER BY reviewsub DESC LIMIT $offset, $no_of_records_per_page ");
$result->execute();
?>
<?php while ($row = $result->fetch(PDO::FETCH_ASSOC)) {// Important line !!! Check summary get row on array .. ?>
<?php
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
?>
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images " src="Images/Reviews/<?php echo $row['reviewimage1'];?>" alt="<?php echo $row['reviewtitle'];?>" >
<div class="card-body">
<h5 class="card-title"><?php echo $row['reviewtitle'];?></h5>
<p class="card-text"><?php echo $row['reviewsynop'];?></p>
<a href="Reviews/review-content.php?id=<?php echo $row['id'];?>&reviewtitle=<?php echo $row['reviewtitle'];?>" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: <?php echo $date; ?></small>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="container">
<!-- Pagination Controller -->
<?php
if($total_pages <= 1){
$hidepage = 'none';
}else{
$hidepage = 'flex';
}
?>
<ul class="pagination justify-content-center pagination-mb" style="display: <?php echo $hidepage; ?>">
<li><a class="page-link" href="?pageno=1">First</a></li>
<li class="page-item <?php if($pageno <= 1){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
</li>
<?php for($i = 1; $i <= $total_pages; $i++ ): ?>
<li class="page-item <?php if($pageno == $i) {echo 'active'; } ?>">
<a class="page-link" href="?pageno=<?= $i; ?>"> <?= $i; ?> </a>
</li>
<?php endfor; ?>
<li class="page-item <?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
</li>
<li><a class="page-link" href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>
<!-- Pagination end -->
</div>
</div>
</div>
</div>
<?php include("PHP/footer.php"); ?>
</div>
</body>
<?php include("PHP/js.php"); ?>
<script>
$(document).ready(function(){
$('#link-review,#link-footer-review').addClass('active');
});
</script>
<script type="text/javascript">
$(document).ready(function(){
function get_filter_text(text_id){
var filterData = [];
$('#'+text_id+':checked').each(function(){
filterData.push($(this).val());
});
return filterData;
}
$(".product_check").click(function(){
if ($(this).prop('checked')) {
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("Filtered Reviews");
}
});
} else {
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("All Reviews");
}
});
}
});
});
</script>
reviewaction.php:
<?php
if(isset($_POST['action'])){
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
// Prev + Next
$prev = $pageno - 1;
$next = $pageno + 1;
$checksql = "SELECT COUNT(*) FROM review_db WHERE reviewcat !=''";
$sql = "SELECT * FROM review_db WHERE reviewcat !=''";
if(isset($_POST['reviewcat'])){
$reviewcat = implode("','", $_POST['reviewcat']);
$checksql .="AND reviewcat IN('".$reviewcat."')";
$sql .="AND reviewcat IN('".$reviewcat."')";
}
$resultpag = $conn->prepare($checksql);
$resultpag->execute();
$total_rows = $resultpag->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql .="ORDER BY reviewsub DESC LIMIT $offset, $no_of_records_per_page ";
$result = $conn->prepare($sql);
$result->execute();
$output='';
if (count($result) > 0) {
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
$output .= '
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images" src="Images/Reviews/'.$row['reviewimage1'].'" alt="'.$row['reviewtitle'].'" >
<div class="card-body">
<h5 class="card-title">'.$row['reviewtitle'].'</h5>
<p class="card-text">'.$row['reviewsynop'].'</p>
<a href="Reviews/review-content.php?id='.$row['id'].'&reviewtitle='.$row['reviewtitle'].'" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: '.$date.'</small>
</div>
</div>
</div>
</div>
';
} //While Loop End
}else{
$output = "<h3>No Reviews Found!</h3>";
}
echo $output;
}
?>
You can do it a couple of ways. One is to add the filter to the GET URI parameters of each page link at the end of your filter function, and add code that marks the filters as selected/checked if the parameters exist in the URI before running the POST request. The other is to change the code so that pagination is done with the same POST request instead of actually navigating to a new URL.
Hosting company updated servers or added new patchs can't get a straight answer.
I updated code looked online and stuck. Tried to have hosting check with server and company keeps coming back and saying its the code.
Don't know what else to do and help would be appreciated.
<?
include_once("mysql_nitrousgarage.inc");
$clean_url = substr($PHP_SELF,1);
$clean_url = substr($clean_url,0,-5);
$q = "SELECT * from NG_product where active='Y' and
clean_url='$clean_url'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$product_id = $row["product_id"];
$product_name = $row["product_name"];
$sku = $row["sku"];
$description = $row["description"];
$meta_title = $row["meta_title"];
$meta_description = $row["meta_description"];
$magiczoomplus = "Y";
include_once("topnav.inc")
?>
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<meta name="viewport" content="width=400, user-scalable=no">
<script type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-
52f96c9761c7b0cb" async="async"></script>
<div class="box-border">
Home ›
<?
if ($saved_category_id || !$saved_brand_id)
{
if ($saved_category_id)
$q = "SELECT * from NG_category where
category_id='$saved_category_id'";
else
$q = "SELECT * from NG_product_category as pc, NG_category
as c where pc.product_id='$product_id' and
pc.category_id=c.category_id order by c.order_placement limit 1";
$results = mysql_nitrousgarage.inc($q);
$row = mysql_fetch_array($results);
$category_id = $row["category_id"];
$category = $row["category"];
$category_clean_url = $row["clean_url"];
echo "<a href='$category_clean_url'>$category Wheels</a>";
}
else
{
$q = "SELECT * from NG_brand where brand_id='$saved_brand_id'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$brand_id = $row["brand_id"];
$brand = $row["brand"];
$brand_clean_url = $row["clean_url"];
echo "<a href='$brand_clean_url'>$brand Wheels</a>";
}
?>
› <?echo $product_name?>
<div class="page-numbers">
<a href="<?echo $category_clean_url?>">‹ Back to <?echo
$category?> Wheels</a>
</div>
</div>
<div class="space20"></div>
<?
$image_id_arr = array();
$q1 = "SELECT * from NG_finish as f, NG_product_finish as pf, NG_finish_image as fi where f.active='Y' and f.finish_id=pf.finish_id and pf.active='Y' and pf.product_id='$product_id' and pf.product_finish_id=fi.product_finish_id and fi.active='Y' order by f.order_placement,fi.order_placement";
$r1 = mysql_query($q1);
while ($row1 = mysql_fetch_array($r1))
{
$image_id = $row1["image_id"];
$product_finish_name = $row1["product_finish_name"];
if (!$main_image)
{
$main_image = "finish-$image_id.jpg";
$selected_finish = $product_finish_name;
}
$image_id_arr[] = $image_id;
$product_finish_name_arr[] = $product_finish_name;
}
?>
<div class="simpletable">
<div class="row">
<div class="simplecell details-cll1">
<div id="m-container">
<img class="maxwidth" id="m-img" src="productphotos/<?echo $main_image?>" width=488>
</div>
</div>
<div class="simplecell" style="width: 3%"></div>
<div class="simplecell details-cll2">
<!--<div class="details-share">
<img src="images/facebook.jpg">
<br class="nomobile">
<img src="images/twitter.jpg">
<br class="nomobile">
<img src="images/mail.jpg">
<br class="nomobile">
<img src="images/plus.jpg">
</div>-->
<span class="details-title"><?echo $product_name?></span>
<div class="style-number">Style: <?echo $sku?></div>
<div class="selected-finish">Selected Finish: <span id=finish_layer>
<?echo $selected_finish?></span>
</div>
<div class="space30"></div>
<br>
<div class="simpleinline">
<div class="like-wheel">Like this Wheel?</div>
<div class="more-info-via">GET MORE INFO VIA</div>
</div>
<div class="simpleinline">
<a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=C">CALL/TEXT</a> <a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=E">EMAIL</a>
</div>
<div class="space50 nomobile"></div>
<div class="space30"></div>
<?
while(list($k,$v) = each($image_id_arr))
{
$product_finish_name = $product_finish_name_arr[$k];
echo "<img class='maxwidth' src='productphotos/finish-$v.jpg' width=145>";
}
?>
</div>
</div>
</div>
<div class="space20"></div>
<div class="box-border">
<div class="simpletable">
<div class="row">
<div class="simplecell product-desc">
<?echo $description?>
</div>
<!--<div class="simplecell price-notshow">
<b>Why are prices not shown?</b>
<br><br>
Many of our customers frequently ask us why are the prices not show.
</div>-->
</div>
</div>
</div>
<div class="space20"></div>
<?
$q = "SELECT * FROM NG_gallery WHERE active='y' and product_id='$product_id' ORDER BY featured desc, orderplacement limit 3";
$results = mysql_query($q);
if (mysql_num_rows($results) > 0) { ?>
<b><?echo $product_name?></b> Vehicle Gallery
<div class="page-numbers">
CLICK IMAGE TO <b>ENLARGE | VIEW MORE</b>
</div>
<?
while ($row = mysql_fetch_array($results))
{
$gallery_id = $row["gallery_id"];
$gallery_title = $row["gallery_title"];
$gallery_pics .= "<a href='productphotos/gallery_$gallery_id-l.jpg' class='MagicZoomPlus' id='Zoomer$gallery_id' rel='zoom-position: inner; zoom-width:400px;zoom-height:500px;' title='$gallery_title'><img class='maxwidth' src='productphotos/gallery_$gallery_id-l.jpg' width=380 border=0></a>";
}
?>
<div class="details-img-container">
<nobr>
<?echo $gallery_pics?>
</nobr>
</div>
<div class="details-img-container2">
<?echo $gallery_pics?>
</div>
<?}?>
<? include_once("footer.inc") ?>
Before updates of server page was working fine.
I'm building php mysql app for job interviews, and I want to have for admin filer with bootstrap panels which are sorted by date in the same color column.
$db = connectPDO();
$query = ("SELECT razgovori.*, djelatnik.ime, djelatnik.prezime
FROM razgovori INNER JOIN djelatnik
ON djelatnik.id = razgovori.insert_by
ORDER BY datum_raz ASC");
$stmt = $db->prepare($query);
$stmt->execute();
$count = $stmt->rowCount();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$date = strtotime($row['datum_raz']);
$twoDaysAgoStart = strtotime('-2 day 00:00:00');
$yesterdayEnd = strtotime('yesterday 23:59:59');
$todayStart = strtotime('today 00:00:00');
$todayEnd = strtotime('today 23:59:59');
$tomorrowStart = strtotime('tomorrow 00:00:00');
$twoDaysAheadEnd = strtotime('+2 day 23:59:59');
<div class="container">
<div class="row">
<?php while ($row = $stmt->fetch(PDO::FETCH_ASSOC)): ?>
<?php $date = strtotime($row['datum_raz']); ?>
<?php if ($twoDaysAgoStart < $date && $yesterdayEnd > $date): ?>
<!--Panel info if past time Job interviews-->
<div class="col-md-4 pull-left">
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title"><?php echo
datumVrijemeSQLuHR($row['datum_raz']); ?></h3></div>
<div class="panel-body">
<div class="col-md-9">
<h5><a href="editRazgovori.php?id=<?php echo $row['id']; ?>"><?php
echo $row['rime'].' '.$row['rprezime']; ?></a></h5>
<?php echo $row['kontakt_br']; ?>
</div>
<div class="col-md-3">
<span class="label label-default pull-right"></h5><?php echo
$row['ime'].' '.$row['prezime']; ?></span>
</div>
</div>
</div>
</div>
<!--//Panel-->
</tr>
<tr>
<!--Panel primary if Job interview is today-->
<?php elseif ($todayStart <= $date && $todayEnd >= $date): ?>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title"><?php echo
datumVrijemeSQLuHR($row['datum_raz']); ?></h3></div>
<div class="panel-body">
<div class="col-md-9">
<h5><a href="editRazgovori.php?id=<?php echo $row['id']; ?>"><?php echo
$row['rime'].' '.$row['rprezime']; ?></a></h5>
<?php echo $row['kontakt_br']; ?>
</div>
<div class="col-md-3">
<span class="label label-default pull-right"></h5><?php echo
$row['ime'].' '.$row['prezime']; ?></span>
</div>
</div>
</div>
</div>
</tr>
<tr>
<!--Panel warning if Job interview is tomorrow-->
<?php elseif ($tomorrowStart <= $date && $twoDaysAheadEnd >= $date): ?>
<div class="col-md-4 pull-right">
<div class="panel panel-warning">
<div class="panel-heading"><h3 class="panel-title"><?php echo
datumVrijemeSQLuHR($row['datum_raz']); ?></h3></div>
<div class="panel-body">
<div class="col-md-9">
<h5><a href="editRazgovori.php?id=<?php echo $row['id']; ?>"><?php
echo $row['rime'].' '.$row['rprezime']; ?></a></h5>
<?php echo $row['kontakt_br']; ?>
</div>
<div class="col-md-3">
<span class="label label-default pull-right"></h5><?php echo
$row['ime'].' '.$row['prezime']; ?></span>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div><!--/row-->
</div><!--/container-->
I want to have sorted like thiswith Main Panal or without
I get this:enter image description here
Because stackoverflow red message constantly asking me for more details, i can't put my all php code
You can do this in your MySQL query.
Example:
SELECT * FROM t1
ORDER BY key_part1, key_part2;
SELECT * FROM t1
WHERE key_part1 = constant
ORDER BY key_part2;
SELECT * FROM t1
ORDER BY key_part1 DESC, key_part2 DESC;
SELECT * FROM t1
WHERE key_part1 = 1
ORDER BY key_part1 DESC, key_part2 DESC;
SELECT * FROM t1
WHERE key_part1 > constant
ORDER BY key_part1 ASC;
SELECT * FROM t1
WHERE key_part1 < constant
ORDER BY key_part1 DESC;
SELECT * FROM t1
WHERE key_part1 = constant1 AND key_part2 > constant2
ORDER BY key_part2;
More information can be found here: https://dev.mysql.com/doc/refman/5.7/en/order-by-optimization.html or https://www.w3schools.com/sql/sql_orderby.asp
If you want to do this inside PHP you can use sort:
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}
?>
The above example will output:
fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] =
orange
More information about PHP sort():
http://php.net/manual/en/function.sort.php
Got some trouble when i tried to use an url to image.
<div class="col-lg-12">
<h1 class="page-header">Anime!</h1>
</div>
<?php
include "config/database.php";
$sql = "SELECT * FROM anime WHERE status = 'On Going' ORDER BY id";
$query = mysql_query($sql);
if ($query > 0){
?>
<div class="container">
<div class="description-plate">
<?php
while
($row = mysql_fetch_array($query)){
$id = $row['id'];
$image = $row['image'];
$title = $row['title'];
$genre = $row['genre'];
$start = $row['start'];
$schedule = $row['schedule'];
$description = $row['description'];
?>
<!--div class="caption-btm">
<p style="margin-left:6px; margin-top:175px;">Start Airing From:</p>
<h5 style="margin-left:10px;"><?php echo $start; ?></h5>
<p style="margin-left:6px;">Airing Schedule:</p>
<h5 style="margin-left:10px;"><?php echo $schedule; ?></h5>
</div-->
<div class="thumbnail-fluid">
<a href="<?php echo $row['image']; ?>">
<div id="og-plate">
<div><img src="admin/<?php echo $row['image']; ?>"></div>
<?php } ?>
</div>
</a>
</div>
</div>
<?php } ?>
</div>
So when i tried to call the image using php, the tag only appear on the last image. What i'm trying to do is having the tag on every images. Would appreciate any help, thanks :)
Right now you are going through the loop (not sure why you are using while) and each time creating
<div class="thumbnail-fluid">
<a href="<?php echo $row['image']; ?>">
<div id="og-plate">
<div><img src="admin/<?php echo $row['image']; ?>"></div>
<?php } ?>
</div>
</a>
</div>
What you want to do is build up an html string on each pass appending the next image tag, something more like
...
$myimages = '';
while // skipped details
$myimages .= ' <div class="thumbnail-fluid">
<a href=". $row['image'] . '>
<div id="og-plate">
<div><img src="admin/' . $row['image'] . '></div>'
. '</div>
</a>
</div>';
}
Its appear last image because ORDER BY id and the condition status = 'On Going' can return one image. Your html structure should be like this.
<div class="col-lg-12">
<h1 class="page-header">Anime!</h1>
</div>
<?php
include "config/database.php";
$sql = "SELECT * FROM anime WHERE status = 'On Going' ORDER BY id";
$result = mysql_query($sql);
$n = mysql_num_rows($result);
if ($n > 0) {
?>
<div class="container">
<div class="description-plate">
<?php
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$image = $row['image'];
$title = $row['title'];
$genre = $row['genre'];
$start = $row['start'];
$schedule = $row['schedule'];
$description = $row['description'];
?>
<div class="thumbnail-fluid">
<a href="<?php echo $row['image']; ?>">
<div id="og-plate">
<div><img src="admin/<?php echo $row['image']; ?>"></div>
</div>
</a>
</div>
<?php } ?>
</div>
</div>
<?php } ?>