Pages and gallery Problems - php

Php / mysql gallery issues
I have made a gallery in php. It receives from an index page an "inname" parameter. The gallery every time it passes from page does not manage to send 2 parameters at the same time and in all inombre. Unparameter of the database "idtext"
Please tell me the mistakes
enter code here
index.php
Lista de Acontecimientos<Br />
<?php
$conexion = mysqli_connect("localhost", "root", "") or trigger_error(mysql_error(),E_USER_ERROR);
mysqli_select_db($conexion,"db674013292");
$consulta="Select * from textos where clase=1 ";
$result=mysqli_query($conexion,$consulta);
?>
<?php
while($fila=mysqli_fetch_row($result)){
echo "".$fila['1']."<br>"; }
?>
Gallery.php
$inombre=$_GET['inombre'];
$objConnect = mysql_connect("localhost","root","") or die(mysql_error());
$objDB = mysql_select_db("db674013292");
$strSQL = "SELECT * FROM galeriadecidiendo where idtexto =$inombre ";
$objQuery = mysql_query($strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 8; // Per Page
#$Page = $_GET["Page"];
if(!#$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by idgaleriatexto ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
echo"<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
echo "<td>";
$intRows++;
?>
<img with="150" height="150" src="<?=$objResult["url"]; ?>"><br>
<?PHP
echo"</td>";
if(($intRows)%4==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
<br>
<span class="paguinas">Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :</span>
<?PHP
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&$inombre=idtexto'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&$inombre=idtexto'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page$Prev_Page&$inombre=idtexto'>Next>></a> ";
}`enter code here`
?>
<?PHP
mysql_close($objConnect);
?>
</body>
</html>

Thanks for the comment.
I have already changed the code to mysqli but the problem persists since I wrongly send the parameter inname every time that page step please as I send it
<html><head></head><body>
<?php
$inombre=$_GET['inombre'];
$objConnect = mysqli_connect("localhost","root","") or die(mysql_error());
$objDB = mysqli_select_db($objConnect,"db674013292");
$strSQL = "SELECT * FROM galeriadecidiendo where idtexto =$inombre ";
$objQuery = mysqli_query($objConnect,$strSQL);
$Num_Rows = mysqli_num_rows($objQuery);
$Per_Page = 8;
?>
#$Page = $_GET["Page"];
if(!#$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{$Num_Pages =1;}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by idgaleriatexto ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysqli_query($objConnect,$strSQL);
echo"<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
$intRows = 0;
while($objResult = mysqli_fetch_array($objQuery))
{
echo "<td>";
$intRows++;
<img with="150" height="150" src="<?=$objResult["url"]; ?>"><br>
echo"</td>";
if(($intRows)%4==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
<span class="paguinas">Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :</span>
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&$inombre=idtexto'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&$inombre=idtexto'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME] Page=$Next_Page$Prev_Page&$inombre=idtexto'>Next>></a> ";
}
mysqli_close($objConnect);

Related

PHP MSSQL Pagination doesn't go to the next page

<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
$sql_name = 'test';
$sql_user = 'sa';
$sql_pass = '';
$dbConn = odbc_connect("Driver={SQL Server};Server={$sql_name};",$sql_user,$sql_pass) or die('Database Connection Error!');
if (!$dbConn) {
exit("Connection failed:".odbc_errormsg());
}
$strSQL = "SELECT * FROM test_db.dbo.test ORDER BY ID ASC ";
$objExec = odbc_exec($dbConn, $strSQL) or die ("Error Execute [".$strSQL."]");
$Num_Rows = 0;
while(odbc_fetch_row($objExec))$Num_Rows++; // Count Record
$Per_Page = 22; // Per Page
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page)+1;
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$Page_End = $Per_Page * $Page;
if($Page_End > $Num_Rows)
{
$Page_End = $Num_Rows;
}
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">ID </div></th>
<th width="98"> <div align="center">Name </div></th>
</tr>
<?php
for($i=$Page_Start;$i<=$Page_End;$i++)
{
$objResult = odbc_fetch_array($objExec,$i);
?>
<tr>
<td><div align="center"><?=$objResult["ID"];?></div></td>
<td><?=$objResult["Name"];?></td>
</tr>
<?php
}
?>
</table>
<br>
Total <?php echo $Num_Rows;?> Record : <?php echo $Num_Pages;?> Page :
<?php
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
odbc_close($dbConn);
?>
</body>
</html>
When I press the button to go to the next page or any other page number it stays on the same page but if I change $Page=2; It will go to page 2 and when pressed to go to another page, it will stay at the same page.

Pagination doesn't work

I am going to make a pagination for my members page, I have a created 8 pagination numbers from 1 to 8 so that when i click on each page , it should display only 1 row of particular database table,database table consists of 8 rows, But in my code when i click , correct page numbers are passing but it doesn't update and display particular selected pagination row , please can u help me in getting solution to this please.
members.php
<?php
include('assets/page_header.php');
include('db/db.php');
$page="";
if(isset($_GET['page']))
{
$page=$_GET['page'];
}
?>
<html>
<head><title></title>
<style>
h1 {
text-align:center;
}
</style>
</head>
<?php
/*$memno=mysql_real_escape_string($_POST['memno']);
$memname=mysql_real_escape_string($_POST['name']);
$address=mysql_real_escape_string($_POST['address']);
$phonenumber=mysql_real_escape_string($_POST['phno']);
$renewaldate=mysql_real_escape_string($_POST['renewaldate']);
$maxborrowlimit=mysql_real_escape_string($_POST['maxborrowlimit']);
$status=mysql_real_escape_string($_POST['status']);*/
?>
<h1>MEMBERS PAGE</h1>
<?php
$str="select * from member LIMIT 1,1 ";
$query1=mysql_query($str);
echo "<table align='center'>";
echo "<tr><th><MemberNumber</th><th>MemberName</th><th>Address</th><th>Phonenumber</th><th>RenewalDate</th><th>MaxBorrowLimit</th><th>Status</th><th colspan=2>Action</th></tr>";
while($query2=mysql_fetch_array($query1))
{
echo "<tr>";
echo "<td>".$query2['memno']."</td>";
echo "<td>".$query2['name']."</td>";
echo "<td>".$query2['address']."</td>";
echo "<td>".$query2['phno']."</td>";
echo "<td>".$query2['renewaldate']."</td>";
echo "<td>".$query2['maxborrowlimit']."</td>";
echo "<td>".$query2['status']."</td>";
echo "<td><button class='button1' data-toggle='tooltip' title='Delete' id=".$query2['memno']." value='delete' name='delete'><img id='image' src='./images/trash.png'/></button></td>";
echo "<td><a id='colour' class='tooltip' href='membereditform.php?mem_no=".$query2['memno']."'><img id='image' src='./images/small.gif'/><span class='tooltiptext' >Edit</span></a></td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
if($page=="" || $page=='1')
{
$page1=0;
}
else
{
$page1=($page*4)-4;
}
$query1=mysql_query("select * from member");
$count=mysql_num_rows($query1);
$s=$count/1;
echo $s;
echo "<br>";
for($i=1;$i<=$s;$i++)
{
?><a href="members.php?page=<?php echo $i ?>" style="text-decoration":none,"Text-align":center;><?php echo $i?></a><?php
}
?>
Try your code like this:
<?php
include('assets/page_header.php');
include('db/db.php');
?>
<html>
<head><title></title>
<style>
h1 {
text-align:center;
}
</style>
</head>
<?php
/*$memno=mysql_real_escape_string($_POST['memno']);
$memname=mysql_real_escape_string($_POST['name']);
$address=mysql_real_escape_string($_POST['address']);
$phonenumber=mysql_real_escape_string($_POST['phno']);
$renewaldate=mysql_real_escape_string($_POST['renewaldate']);
$maxborrowlimit=mysql_real_escape_string($_POST['maxborrowlimit']);
$status=mysql_real_escape_string($_POST['status']);*/
?>
<h1>MEMBERS PAGE</h1>
<?php
$num_rec_per_page = 10;
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$str = "select * from member LIMIT $start_from, $num_rec_per_page";
$query1=mysql_query($str);
echo "<table align='center'>";
echo "<tr><th><MemberNumber</th><th>MemberName</th><th>Address</th><th>Phonenumber</th><th>RenewalDate</th><th>MaxBorrowLimit</th><th>Status</th><th colspan=2>Action</th></tr>";
while($query2=mysql_fetch_array($query1))
{
echo "<tr>";
echo "<td>".$query2['memno']."</td>";
echo "<td>".$query2['name']."</td>";
echo "<td>".$query2['address']."</td>";
echo "<td>".$query2['phno']."</td>";
echo "<td>".$query2['renewaldate']."</td>";
echo "<td>".$query2['maxborrowlimit']."</td>";
echo "<td>".$query2['status']."</td>";
echo "<td><button class='button1' data-toggle='tooltip' title='Delete' id=".$query2['memno']." value='delete' name='delete'><img id='image' src='./images/trash.png'/></button></td>";
echo "<td><a id='colour' class='tooltip' href='membereditform.php?mem_no=".$query2['memno']."'><img id='image' src='./images/small.gif'/><span class='tooltiptext' >Edit</span></a></td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
$sql = "select * from member";
$rs_result = mysql_query($sql); //run the query
$total_records = mysql_num_rows($rs_result); //count number of records
$total_pages = ceil($total_records / $num_rec_per_page);
if($total_records > 0) {
echo "<a href='members.php?page=1'> ".'<'." </a> "; // Goto 1st page
}
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='members.php?page=".$i."'> ".$i." </a> ";
};
if($total_records > 0) {
echo "<a href='members.php?page=$total_pages'> ".'>'." </a> "; // Goto last page
}
?>
</html>

Pagination links disappear when clicked on the next or any other page

I'm having a problem with PHP pagination.
When I click on the next page to see next results, pagination links and data just disappear.
I tried various Pagination classes, but decided to stop on this solution.
Will be extremely grateful if someone helps to find a fix.
<html>
<head>
<title></title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<?Php
require "config_pag.php";
$field = $_POST['field'];
$state = $_POST['state'];
$page_name="search.php";
$start=$_GET['start'];
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0);
$limit = 2;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$nume = $dbo->query("select count(id) from posts WHERE state = '$state' AND field = '$field'")->fetchColumn();
echo "<TABLE class='t1'>";
echo "<tr><th>ID</th><th>State</th><th>Fields</th><th>Description</th></tr>";
$query=" SELECT * FROM posts WHERE state = '$state' AND field = '$field' limit $eu, $limit ";
foreach ($dbo->query($query) as $row) {
$m=$i%2;
$i=$i+1;
echo "<tr class='r$m'><td>".$row['id']."</td><td>".$row['state']."</td><td>".$row['field']."</td><td>".$row['description']."</td></tr>";
}
echo "</table>";
if($nume > $limit ){
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
if($back >=0) {
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
if($this1 < $nume) {
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";
}
?>
</html>

search and pagination not work

hello I try to combine the two scripts from the book PHP 6 and MySQL 5 for Dynamic Web Sites. I did search and pagination, but when I go to the next page - did not work.
I posted two screenshots below.
if someone could show me how I make a mistake I will be grateful.
<?php require_once("../../includes/functions_2.php"); ?>
<?php
//database connect
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "1qazxsw2";
$dbname = "dw_bookstore";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
//sprawdzenie polaczenia
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//zmaiana znako na utf8
if (!mysqli_set_charset($connection, "utf8")) {
printf("Error loading character set utf8: %s\n", mysqli_error($connection));
} else {
//printf("Kodowanie ustawione na: %s\n", mysqli_character_set_name($connection));
}
?>
<?php
// Number of records to show per page:
$display = 3;
// Determine how many pages there are...
if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined.
$pages = $_GET['p'];
} else { // Need to determine.
#$query = $_GET['query'];
$query4 = "SELECT COUNT(id) ";
$query4 .= "FROM photographs ";
$query4 .= "WHERE `nazwa` LIKE '%".$query."%' ";
//$query .= "WHERE visible = 1 ";
$result = #mysqli_query ($connection, $query4);
$row = #mysqli_fetch_array ($result, MYSQLI_NUM);
$records = $row[0];
// Count the number of records:
if ($records > $display) { // More than 1 page.
$pages = ceil ($records/$display);
} else {
$pages = 1;
}
} // End of p IF.
// Determine where in the database to start returning results...
if (isset($_GET['s']) && is_numeric($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
// Make the query:
#$query = $_GET['query'];
$query3 = "SELECT * ";
$query3 .= "FROM photographs ";
$query3 .= "WHERE `nazwa` LIKE '%".$query."%' ";
$query3 .= "OR `kod` LIKE '%".$query."%' ";
//$query .= "AND visible = 1 ";
$query3 .= "ORDER BY id ASC LIMIT $start, $display ";
$result3 = mysqli_query ($connection, $query3);
?>
<?php
// 2. Perform database query
$query2 = "SELECT * ";
$query2 .= "FROM photographs ";
//$query2 .= "WHERE visible = 1 ";
$query2 .= "ORDER BY nazwa ASC ";
$result2 = mysqli_query($connection, $query2);
// Test if there was a query error
if (!$result2) {
die("Database query failed.");
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>List_n01</title>
<link href="../../stylesheets/main_2.css" rel="stylesheet" type="text/css" media="screen, projection" />
</head>
<body>
<div id="wrapper">
<div id="header">
<h2>Cennik: Panel Administracyjny</h2>
</div>
<div id="mainContent">
<h1>Graphic Design</h1>
<?php
// Count the number of returned rows:
$num = mysqli_num_rows($result2);
if ($num > 0) { // If it ran OK, display the records.
// Print how many rows there are:
echo "<p>W bazie znajduje się $num pozycji.</p>\n"; ?>
<form action="<?php echo $_SERVER ['PHP_SELF']; ?>" method="GET">
<fieldset>
<ul class="formList">
<li>
<input type="text" name="query" placeholder="Szukana fraza... " />
<input type="submit" value="Search" />
</li>
</fieldset>
</form>
<table id="article">
<caption></caption>
<colgroup>
</colgroup>
<tr>
<th>Zdjęcie:</th>
<th>Typ:</th>
<th>Wielkość:</th>
<th>Nazwa:Nazwa:</th>
<th>Kod:</th>
<th>Edytuj:</th>
<th>Szczegóły:</th>
<th>Usuń:</th>
</tr>
<?php
// 3. Use returned data (if any)
while($row = mysqli_fetch_assoc($result3)) {
// output data from each row
?>
<tr>
<td><img src="../images/<?php echo $row['filename']; ?>" width="150" class="article" /></td>
<td><?php echo $row['type']; ?></td>
<td><?php echo size_as_kb($row['size']); ?></td>
<td><?php echo $row['nazwa']; ?></td>
<td><?php echo $row['kod']; ?></td>
<td>Edytuj</td>
<td>Detale</td>
<td>{Usuń}</td>
</tr>
<?php
}
?>
</table>
<?php
// 4. Release returned data
mysqli_free_result($result3);
} else { // If no records were returned.
echo '<p class="error">There are currently no rows.</p>';
}
?>
<?php
// Make the links to other pages, if necessary.
if ($pages > 1) {
echo '<br /><p>';
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button:
if ($current_page != 1) {
echo 'Previous ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
$distance = $current_page - $i;
if (abs($distance) < 5){
echo '' . $i . ' ';
}
} else {
echo $i . ' ';
}
} // End of FOR loop
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo 'Next';
}
echo '</p>'; // Close the paragraph.
} // End of links section.
?>
</div>
<div id="footer">
<p>Copyright <?php echo date("Y", time()); ?>, Cleoni</p></div>
</div>
</body>
</html>
<?php
// 5. Close database connection
mysqli_close($connection);
?>
you are facing issues because in your second url, the query parameter is missing, you should have also have the query=car parameter in get as the data that is been searched is searched with that parameter according to the script...
Change code from around line 184-204 to the following
// If it's not the first page, make a Previous button:
if ($current_page != 1) {
echo 'Previous ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
$distance = $current_page - $i;
if (abs($distance) < 5){
echo '' . $i . ' ';
}
} else {
echo $i . ' ';
}
} // End of FOR loop
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo 'Next';
}

How do I not display certain parts of the table from my database?

http://i.stack.imgur.com/5OTgG.png
The image above describes my problem, and provides a visual.
As you can see, I just want to reserve or delete the two spaces on the top-right. How can I achieve this?
This is my current code:
<html>
<head>
</head>
<body>
<?php
$objConnect = mysql_connect("localhost","root","") or die(mysql_error());
$objDB = mysql_select_db("dbname");
$strSQL = "SELECT * FROM album";
if (!isset($_GET['Page'])) $_GET['Page']='0';
$objQuery = mysql_query($strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 12; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by albumID ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
echo "<td>";
$intRows++;
?>
<center>
<img src="https://s3.amazonaws.com/thumbnails/<?=$objResult["Picture"];?>" height="190" width="190" /></a><br>
<?=$objResult["albumName"];?>
<br>
</center>
<?php
echo"</td>";
if(($intRows)%4==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
<br>
<?php
//DELETED PAGINATION CODE for the sake of simplicity in StackOverflow
?>
</body>
</html>
<?php
mysql_close($objConnect);
?>
In your loop, you'd need to put in some conditional statement to break from the default behavior.
while($objResult = mysql_fetch_array($objQuery))
{
if(($intRows)%4==0)
{
echo"<tr>"; // You forgot this.
}
echo "<td>";
$intRows++;
if ($intRows == 3 || $intRows == 4) :
?>
<!-- special cells -->
<?
else:
?>
<center>
<img src="https://s3.amazonaws.com/thumbnails/<?=$objResult["Picture"];?>" height="190" width="190" /></a><br>
<?=$objResult["albumName"];?>
<br>
</center>
<?php
endif;
echo"</td>";
if(($intRows)%4==0)
{
echo"</tr>";
}
}
// You also need this part:
echo ($intRows %4 > 0 ? "</tr>" : "") . "</table>";
Your $intRows variable seems to be counting cells, not rows. So you can simply identify the top right cells by their numbers, which should be 2 and 3. Add this to your loop:
$cell = 0;
echo '<table border="1" cellpadding="2" cellspacing="1"><tr>';
while($objResult = mysql_fetch_array($objQuery))
{
if($cell % 4 == 0) {
echo '</tr><tr>';
}
if($cell == 2 || $cell == 3) {
echo '<td>RESERVED</td>';
} else {
echo '<td>'.$objResult["albumName"].'</td>';
}
$cell++;
}
echo '</tr></table>';

Categories