I currently am having trouble using pagination. The first page is great, and the display on the second and third pages are correct, but the actual $_Get variables are not being carried over onto the second page and third page. Where would I put the actual $_Get Variables to go onto the next pages? Also I am using a form to pass the variables as a hidden input, that again work on the first page, but revert to empty on the second and third pages. I have read about decoupling and using sessions, but have tried implementing session variables at the top to no avail. How would I get the session to go to the second and third page. Thank you!
session_start();
include "dbhReal.inc.php";
include "header.php";
$timeSelected = $_GET['time'];
$dateSelected = $_GET['date'];
$ShownDate = date('M-d-y', strtotime("$dateSelected"));
$Null = '00:00:00';
<!--Form is below, left out the queries for space sake-->
echo '
<div class="col-sm-6">
<div class="card h-100">
<img class="card-img-top" src="../PhotoUploads/uploads/'.$userPic['Link1'].'" height="350" width="400" alt="anotherOne"/>
<div class="card-body">
<h5 class="card-title">'.$row['firstNameP'].' '.$row['lastNameP'].'</h5>
<p class="card-text">'.$row['briefDescription'].'</p>
<form action="settingTheSession.php" method="GET">
<input type="hidden" name="time" value='.$timeSelected.'>
<input type="hidden" name="date" value='.$dateSelected.'>
<input type="hidden" name="idNumber" value='.$boookingNumber.'>
<button type="submit" class="btn btn-primary" name="buttonBookprofileSearch">See Profile</button>
</form>
</div>
</div>
</div>';
<!--Pagnation-->
<ul class="pagination justify-content-center">
<li class="page-item" <?php if($page_no <= 1){ echo "class='page-item disabled'"; } ?>>
<a class='page-link' <?php if($page_no > 1){ echo "href='?page_no=$previous_page'"; } ?>>Previous</a>
</li>
<?php
if ($total_no_of_pages <= 10){
for ($counter = 1; $counter <= $total_no_of_pages; $counter++){
if ($counter == $page_no) {
echo "<li class='page-item active'><a class='page-link'>$counter</a></li>";
}else{
echo "<li class='page-item'><a class='page-link' href='?page_no=$counter'>$counter</a></li>";
}
}
}
elseif($total_no_of_pages > 10){
if($page_no <= 4) {
for ($counter = 1; $counter < 8; $counter++){
if ($counter == $page_no) {
echo "<li class='page-item active'><a class='page-link'>$counter</a></li>";
}else{
echo "<li class='page-item' ><a class='page-link' href='?page_no=$counter'>$counter</a></li>";
}
}
echo "<li class='page-item'><a>...</a></li>";
echo "<li class='page-item'><a class='page-link' href='?page_no=$second_last'>$second_last</a></li>";
echo "<li class='page-item'><a class='page-link' href='?page_no=$total_no_of_pages'>$total_no_of_pages</a></li>";
}
elseif($page_no > 4 && $page_no < $total_no_of_pages - 4) {
echo "<li class='page-item'><a class='page-link' href='?page_no=1'>1</a></li>";
echo "<li class='page-item'><a class='page-link' href='?page_no=2'>2</a></li>";
echo "<li class='page-item'><a class='page-link'>...</a></li>";
for ($counter = $page_no - $adjacents; $counter <= $page_no + $adjacents; $counter++) {
if ($counter == $page_no) {
echo "<li class='page-item active'><a class='page-link'counter</a></li>";
}else{
echo "<li class='page-item'><a class='page-link' href='?page_no=$counter'>$counter</a></li>";
}
}
echo "<li class='page-item'><a class='page-link'>...</a></li>";
echo "<li class='page-item'><a class='page-link' href='?page_no=$second_last'>$second_last</a></li>";
echo "<li class='page-item'><a class='page-link' href='?page_no=$total_no_of_pages'>$total_no_of_pages</a></li>";
}
else {
echo "<li class='page-item'><a class='page-link' href='?page_no=1'>1</a></li>";
echo "<li class='page-item'><a class='page-link' href='?page_no=2'>2</a></li>";
echo "<li class='page-item'><a class='page-link'>...</a></li>";
for ($counter = $total_no_of_pages - 6; $counter <= $total_no_of_pages; $counter++) {
if ($counter == $page_no) {
echo "<li class='page-item active'><a class='page-link'>$counter</a></li>";
}else{
echo "<li class='page-item'><a class='page-link' href='?page_no=$counter'>$counter</a></li>";
}
}
}
}
?>
<li class="page-item" <?php if($page_no >= $total_no_of_pages){ echo "class='disabled'"; } ?>>
<a class="page-link" <?php if($page_no < $total_no_of_pages) { echo "href='?page_no=$next_page'"; } ?>>Next</a>
</li>
<?php if($page_no < $total_no_of_pages){
echo "<li class='page-item'><a class='page-link' href='?page_no=$total_no_of_pages'>Last ››</a></li>";
} ?>
</ul>
<div class="text-center">
<strong>Page <?php echo $page_no." of ".$total_no_of_pages; ?></strong></div>
<br />
At first try not to reinvent the wheel. There are a lot of packages out there which deal with pagination: https://packagist.org/packages/voku/pagination?query=pagination
Secondly, considering your question, as PHP is server side you need to pass the needed data to every page/url you navigate.
So like the following example from your code:
echo "<li class='page-item'><a class='page-link' href='?page_no=1'>1</a></li>";
You will need the add the wanted arguments to the href query string. Like you are already doing with the 'page_no' parameter.
echo "<li class='page-item'><a class='page-link' href='?page_no=1&date=". $dateSelected ."'>1</a></li>";
In that manner you will have access to the wanted arguments on the next pages.
Related
I am learning PHP and was trying to created dynamic pagination to show record form MySQL.
The issue I'm facing is when I change number of record to be show by using SELECT tag it only works once after that it goes back to default value that i have set -> $limit = isset($_POST['records-count'])?$_POST['records-count']:"10"; which is 10.
PHP
include('../config/DbFunction.php');
$obj = new DbFunction();
$limit = isset($_POST['records-count'])?$_POST['records-count']:"10";
$page = isset($_GET['page'])? $_GET['page']:"1";
$start_data = ($page-1)*$limit;
$rs = $obj->view_course($limit,$start_data);
//print_r($limit); // to check limit value
$course_row = mysqli_fetch_row($obj->view_course1());
$total_records = $course_row[0];
$total_page = ceil($total_records/$limit);
$next = $page + 1 > $total_page? $total_page : $page +1;
$prev = $page - 1 == 0? 1 : $page - 1;
?>
Form
<form method="post" action="#">
Records: <select name="records-count" id="records_count">
<option disabled="disabled" selected="selected">Limit</option>
<?php foreach([20,50,100,200] as $limit): ?>
<option <?php if( isset($_POST["records_count"]) && $_POST["records_count"] == $limit) echo "selected" ?> value="<?= $limit; ?>"><?= $limit; ?></option>
<?php endforeach; ?>
</select>
</form>
Pagination
<div class="pagination">
<ul class="pagination pagination-default">
<li class='page-item'><a class='page-link' href="view-course.php?page=<?= $prev; ?>">Previous</a></li>
<?php
for ($i=1; $i<=$total_page; $i++) {
echo "<li class='page-item'><a class='page-link' href='view-course.php?page=".$i."'>".$i."</a></li>";
}
?>
<li class='page-item'><a class='page-link' href="view-course.php?page=<?= $next; ?>">Next</a></li>
</ul>
</div>
you may need to store and retrieve it from session. Session will allow to store variable in server
you need to start the session before send anything to client.
session_start();
if(isset($_POST['records-count']))
$_SESSION["records-count"] = $_POST['records-count'];
last thing to note is:
session variable will be updated in next requests.
After so many try I got the solution by using GET method
So i Change
$limit = isset($_POST['records-count'])?$_POST['records-count']:"10";
<div class="pagination">
<ul class="pagination pagination-default">
<li class='page-item'><a class='page-link' href="view-course.php?page=<?= $prev; ?>">Previous</a></li>
<?php
for ($i=1; $i<=$total_page; $i++) {
echo "<li class='page-item'><a class='page-link' href='view-course.php?page=".$i."'>".$i."</a></li>";
}
?>
<li class='page-item'><a class='page-link' href="view-course.php?page=<?= $next; ?>">Next</a></li>
</ul>
</div>
to
if (isset($_POST['records-count'])) {
$limit = $_POST['records-count'];
} else {
$limit = empty($_GET['records'])? "2":$_GET['records'];
}
<div class="pagination">
<ul class="pagination pagination-default">
<li class='page-item'><a class='page-link' href="view-course.php?page=<?= $prev; ?>&records=<?= $limit; ?>">Previous</a></li>
<?php
for ($i=1; $i<=$total_page; $i++) {
echo "<li class='page-item'><a class='page-link' href='view-course.php?page=".$i."& records=".$limit."'>".$i."</a></li>";
}
?>
<li class='page-item'><a class='page-link' href="view-course.php?page=<?= $next; ?>&records=<?= $limit; ?>">Next</a></li>
</ul>
</div>
If anyone know more efficient or better way then this plz let me know.
Am new to php, i am try to use pagenation , where i post a unique id to a page then use that to load content with the respective id then pagenate all the content with that respective id.
Here below is what have been trying
<?php
if (isset($_GET["post"]))
{
$page = $_GET["post"];
} else
{
$page = 1;
};
$limit = 2;
$total_records = $pagination;
$total_pages = ceil($total_records/$limit);
$lastpage = ceil($total_pages/$limit);
$page != 0;
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
//lastpage is = total pages / items per page, rounded up.
if($prev == 0)
$prev = 1;
$next <= $lastpage;
//if no page var is given, default to 1.
$pagLink = "<ul class='pagination pagination-circle' class='justify- content-center'>";
$pagLink .= "<li class='page-item active'>
<a class='page-link black' href='home.php?post=".$prev."' aria-label='Back'>
<span aria-hidden='true'>«</span>
<span class='sr-only'>Next</span>
</a>
</li>";
for ($i=1; $i<=$total_pages; $i++) {
$pagLink .= "<li class='page-item active'><a class='page-link' href='home.php?post=".$i."'>".$i."</a></li> ";
};
$pagLink .= "<li class='page-item pg-red active'>
<a class='page-link black' href='home.php?post=".$next."' aria-label='Next'>
<span aria-hidden='true'>»</span>
<span class='sr-only'>Next</span>
</a>
</li>";
echo $pagLink . "</ul>";
?>
Here is how i want to pagenate contents per id
enter image description here
I am learning PHP. I am trying to use pagination in my one of page. If its first page, all is working fine but as soon as I press next page button its giving me error like
Notice: Undefined index: number1 in C:\xampp\htdocs\mycode\compare.php on line 6
Notice: Undefined index: number2 in C:\xampp\htdocs\mycode\compare.php on line 7
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\mycode\compare.php on line 18
I think its due to $_GET which I am using in line 6 and 7 but I do not know why its getting destroyed as soon as I try to go on next page. My full code is like below
<?php include("includes/header.php");
require("includes/function.php");
require("language/language.php");
$number1 = $_GET['number1'];
$number2 = $_GET['number2'];
$tableName="number_status";
$targetpage = "compare.php";
$limit = 10;
$sr=0;
$query = "SELECT COUNT(*) as num FROM $tableName WHERE number = $number1 OR number = $number2 ";
$total_pages = mysqli_fetch_array(mysqli_query($mysqli,$query));
$total_pages = $total_pages['num'];
$stages = 3;
$page=0;
if(isset($_GET['page'])){
$page = mysqli_real_escape_string($mysqli,$_GET['page']);
}
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
$quotes_qry="SELECT * FROM number_status WHERE number = $number1 OR number = $number2 ORDER BY id DESC LIMIT $start, $limit";
$result=mysqli_query($mysqli,$quotes_qry);
?>
<div class="row">
<div class="col-xs-12">
<div class="card mrg_bottom">
<div class="page_title_block">
<div class="col-md-5 col-xs-12">
<div class="page_title">Number Details</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row mrg-top">
<div class="col-md-12">
<div class="col-md-12 col-sm-12">
<?php if(isset($_SESSION['msg'])){?>
<div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<?php echo $client_lang[$_SESSION['msg']] ; ?></a> </div>
<?php unset($_SESSION['msg']);}?>
</div>
</div>
</div>
<div class="col-md-12 mrg-top">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>#SR</th>
<th>Number</th>
<th>Online Time</th>
<th>Offline Time</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<?php
$i=0;
while($row=mysqli_fetch_array($result))
{
$number = $row['number'];
$start_time = "<span style='color:green;'>".$row['start_time']."</span>";
$end_time = "<span style='color:red'>".$row['end_time']."</span>";
$tmp = strtotime($row['end_time']) - strtotime($row['start_time']);
$duration = floor($tmp/3600) . ":" . floor($tmp/60) . ":" . ($tmp%60);
?>
<tr>
<td><?php echo ++$sr+$start;?></td>
<td><?php echo $number ?></td>
<td><?php echo nl2br($start_time);?></td>
<td><?php echo nl2br($end_time);?></td>
<td><?php echo nl2br ($duration); ?></td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
</div>
<div class="col-md-12 col-xs-12">
<div class="pagination_item_block">
<nav>
<?php if(!isset($_POST["quotes_search"])){ include("pagination.php");}?>
</nav>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php include("includes/footer.php");?>
My pagination.php is like this
<?php
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
$paginate = '';
if($lastpage > 1)
{
$paginate .= "<ul class='pagination'>";
// Previous
if ($page > 1){
$paginate.= "<li><a href='$targetpage?page=$prev' aria-label='Previous'><span aria-hidden='true'>«</span></a></li>";
}else{
$paginate.= "<li><span aria-hidden='true'>«</span></li>"; }
// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<li class='active'><span class='active'>$counter</span></li>";
}else{
$paginate.= "<li><a href='$targetpage?page=$counter'>$counter</a></li>";}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= "<li class='active'><span class='active'>$counter</span></li>";
}else{
$paginate.= "<li><a href='$targetpage?page=$counter'>$counter</a></li>";}
}
$paginate.= "<li>...</li>";
$paginate.= "<li><a href='$targetpage?page=$LastPagem1'>$LastPagem1</a></li>";
$paginate.= "<li><a href='$targetpage?page=$lastpage'>$lastpage</a></li>";
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
$paginate.= "<li><a href='$targetpage?page=1'>1</a></li>";
$paginate.= "<li><a href='$targetpage?page=2'>2</a></li>";
$paginate.= "<li>...</li>";
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if ($counter == $page){
$paginate.= "<li class='active'><span class='active'>$counter</span></li>";
}else{
$paginate.= "<li><a href='$targetpage?page=$counter'>$counter</a></li>";}
}
$paginate.= "<li>...</li>";
$paginate.= "<li><a href='$targetpage?page=$LastPagem1'>$LastPagem1</a></li>";
$paginate.= "<li><a href='$targetpage?page=$lastpage'>$lastpage</a></li>";
}
// End only hide early pages
else
{
$paginate.= "<li><a href='$targetpage?page=1'>1</a></li>";
$paginate.= "<li><a href='$targetpage?page=2'>2</a></li>";
$paginate.= "<li>...</li>";
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<li class='active'><span class='active'>$counter</span></li>";
}else{
$paginate.= "<li><a href='$targetpage?page=$counter'>$counter</a></li>";}
}
}
}
// Next
if ($page < $counter - 1){
$paginate.= "<li><a href='$targetpage?page=$next' aria-label='Next'><span aria-hidden='true'>»</span></a></li>";
}else{
$paginate.= "<li><span aria-hidden='true'>»</span></li>";
}
$paginate.= "</ul>";
}
// pagination
echo $paginate;
?>
Let me know if someone can look and help me for get out of it.
Thanks
The 2 "notices" mean that the php page was called having omitted the "page" parameter in the query string (for this reason the $_GET['page'] causes an "undefined index" message). The last message means that the "mysqli_query($mysqli,$query)" has returned false, and you cannot use that result as argument to the "mysqli_fetch_array" (you should always check for errors when using DB functions). The query went wrong because $number1 and $number2 were empty because of the previous error.
hello guys can you help me out ?
i have a problem in pagination
i just want to disable the next and previous
button in my pagination if it is
no item left
$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "final";
$con= mysqli_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysqli_select_db($con, "final") or die ("no database");
$pagination_sql = "SELECT * FROM `ongoing` WHERE approved='approve'";
$run_pagination = mysqli_query($con, $pagination_sql);
$count = mysqli_num_rows($run_pagination);
$total_pages = ceil($count/$per_page);
echo "<ul class='pagination'>";
echo "<li class='page-item'><a class='page-link' href='ongoing.php?page=".($page-1)."' class='button'>
<span aria-hidden='true'>«</span>
<span class='sr-only'>Previous</span>
</a></li>";
for($i=1;$i<=$total_pages;$i++){
echo'<li><a class="page-link" href="ongoing.php?page='.$i.'">'.$i.'</a></li>';
};
echo "<li class='page-item'><a class='page-link' href='ongoing.php?page=".($page+1)."' class='button'>
<span aria-hidden='true'>»</span>
<span class='sr-only'>Next</span>
</a></li>";
echo "</ul>";
?>
and here's the condition of per page
$per_page = 10;
if(isset($_GET['page'])){
$page = $_GET['page'];
}else{
$page= 1;
}
$start_from = ($page-1) * $per_page;
I think you just need to adjust your code as below:
echo "<ul class='pagination'>";
if($page == 1) {
$disable_prev = 'disabled';
$prev_url = "javascript:void(0);";
} else {
$disable_prev = '';
$prev_url = "ongoing.php?page=".($page-1);
}
echo "<li class='page-item ".$disable_prev."'><a class='page-link' href='".$prev_url."' class='button'>
<span aria-hidden='true'>«</span>
<span class='sr-only'>Previous</span>
</a></li>";
for($i=1;$i<=$total_pages;$i++){
echo'<li><a class="page-link" href="ongoing.php?page='.$i.'">'.$i.'</a></li>';
};
if($page+1 == $total_pages) {
$disable_next = '';
$next_url = "ongoing.php?page=".($page+1);
} else {
$disable_next = 'disabled';
$next_url = "javascript:void(0);";
}
echo "<li class='page-item ".$disable_next."'><a class='page-link' href='".$next_url."' class='button'>
<span aria-hidden='true'>»</span>
<span class='sr-only'>Next</span>
</a></li>";
echo "</ul>";
Then you can also add some CSS to make disabled li little visible or faded than other
Try:
if($i != NULL){ //NULL or Empty
//Code here
}
I have some PHP code which pulls data from the database and places it in to a three column layout like below:
Column one column two column three
Now this works, the only problem is, the while loop keeps going and it repeats the same data over and over again. If i only have one entry in the database then this is repeated three times and i end up with one column of data. shown here :
http://www.gulfwarmemorial.co.uk/events.php
If I have three entries then the rows get repeated. I have tried various things but nothing seems to work.
$tableName="fundraising_event";
$targetpage = "events.php";
$limit = 6;
$query = "SELECT COUNT(*) as num FROM $tableName";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$stages = 3;
$page = mysql_escape_string($_GET['page']);
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
// Get page data
$query1 = "SELECT *, SUBSTRING(event_details,1,200) AS event_details_short FROM $tableName LIMIT $start, $limit";
$result = mysql_query($query1);
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
$paginate = '';
if($lastpage > 1)
{
$paginate .= "<div class='paginate'>";
// Previous
if ($page > 1){
$paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
}else{
$paginate.= "<span class='disabled'>previous</span>"; }
// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// End only hide early pages
else
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
}
// Next
if ($page < $counter - 1){
$paginate.= "<a href='$targetpage?page=$next'>next</a>";
}else{
$paginate.= "<span class='disabled'>next</span>";
}
$paginate.= "</div>";
}
?>
<?php while($row = mysql_fetch_array($result)){?>
<div class="row-fluid">
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
</div>
<?php } ?>
The issue is that, in turn, you need to fill one event column with the current event from the database. So you need a 'selector for the next row to fill in the next event column.
You have a choice of filling each column in turn, Which is slightly more complex. Or filling the columns horizontally. Which this code attempts to do.
This is all untested code but hopefully shows the logic needed.
<?php $columnSelector = 0; // define a column selector ?>
<?php while($row = mysql_fetch_array($result)) :?>
<?php if ($columnSelector == 0): ?>
<div class="row-fluid">
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<?php elseif ($columnSelector == 1): ?>
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<?php elseif ($columnSelector == 2): ?>
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<?php endif; ?>
</div>
<?php $columnSelector++; // advance to the next row?>
<?php $columnSelector %= 3; // reset to zero every third event?>
<?php endwhile; ?>