Hi all
I have simple PHP News publishing script and it has pagination system.
This script also has an option to display only active news which activated by admin. it displays one big picture at the center and four little picture at the right side.
but it has little shortage. when news section is opened it shows the last news added below and it show numbers of pages that consists 4 news per page. the shortage is when i want to go through 3-rd page instead of big picture it displays the last entered picture. i would like let it displays the first large picture at the third page.
(for ex; every page consists of 4 news and in every page one must be the first )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dahi Tasarim . CoM</title>
<style type="text/css">
<!--
a:link {
color: #0066FF;
text-decoration: underline;
}
a:visited {
text-decoration: underline;
color: #0033CC;
}
a:hover {
text-decoration: none;
color: #FFFFFF;
}
a:active {
text-decoration: underline;
}
-->
</style></head>
<body>
<? // connect php yi yukluyoruz
include("connect.php");
define('MAX_PAGE1', 1);
// bu satэrda adres satэrэndan (GET metodu) no bilgisi gelmiюmi diye kontrol ediyoruz...
$no=$_GET["no"];
//eger $no yoksa demekki talep edilen bir newsin devami yok
//biz en son kaydi veritabanэndan cekiyoruz
$page = intval(@$_GET["page"]);
if (!$no)
{$query=mysql_query("select * from news where active='active' order by no desc limit 1");
}
if (isset($_GET["page"])) {
$db = mysql_connect("localhost", "238147", "19841223") or die("Couldn't connect to db!");
mysql_select_db("238147") or die("Couldn't select db!");
$rs1 = mysql_query("SELECT COUNT(active) FROM news") or die("Count query error!");
list($total) = mysql_fetch_row($rs1);
$page_sayi = ceil($total / MAX_PAGE1);
$page = intval(@$_GET["page"]);
if (0 == $page){
$page = 1;
}
$start = MAX_PAGE1 * ($page - 1);
$max = MAX_PAGE1;
$rs1 = mysql_query("SELECT * FROM news where active='active' ORDER BY no
DESC LIMIT $start, $max") or die("Employee query error!");
}
if ($no)// eger $no varsa istenilen nolu newsi veritabanэndan cekiyoruz
{$query=mysql_query("select * from news where no='$no'");
}
while($row=mysql_fetch_row($query))
{
$title=$row[1];
$subject=$row[2];
$theme=$row[3];
$littleimage=$row[4];
$largeimage=$row[5];
$theme=str_replace ("\n","<br />",$theme);
// \n br ile admin sayfasэnda description kismina girdigimiz enterlari
// br ye cevirip alt row yapiyoruz
}
?>
<table border="1" cellpadding="10" cellspacing="10" bordercolor="#666666" bgcolor="#CCCCCC">
<tr>
<td width="500" valign="top" bgcolor="#FFCC00" name="largeimage">
<?php if ( !empty( $largeimage ) ): ?>
<img alt="" src="<?=$largeimage; ?>">
<?php else: ?>
<img alt="No image" src="/yukle/news_buyuk/noimage.jpeg">
<?php endif; ?>
<div class="indent1">
<h1><?=$title; ?> <span></span></h1>
<p><?=$theme; ?></p></td>
<td width="170" valign="top" bgcolor="#FF9900">
<?
define('MAX_PAGE', 4);
$db = mysql_connect("localhost", "238147", "19841223") or die("Couldn't connect to db!");
mysql_select_db("238147") or die("Couldn't select db!");
$rs = mysql_query("SELECT COUNT(active) FROM news") or die("Count query error!");
list($total) = mysql_fetch_row($rs);
$page_sayi = ceil($total / MAX_PAGE);
$page = intval(@$_GET["page"]);
if (0 == $page){
$page = 1;
}
$start = MAX_PAGE * ($page - 1);
$max = MAX_PAGE;
$rs = mysql_query("SELECT no, littleimage, subject, description, title FROM news where active='active' ORDER BY no
DESC LIMIT $start, $max") or die("Employee query error!");
?>
<?php
while($row1=mysql_fetch_row($rs))
{
$no=$row1[0];
$subject=$row1[2];
$description=$row1[3];
$littleimage=$row1[1];
$title=$row1[4];
?>
<?php
if(file_exists($littleimage)){
echo "<p><a href='index.php?no=$no'>
<img alt='' src='$littleimage' />
<br><span>$title</span></a><br />$subject
</p>";
}
else {
echo "<p><a href='index.php?no=$no'>
<img alt='' src='/yukle/news_buyuk/noimage.jpeg' />
<br><span>$title</span></a><br />$subject
</p>";
}
}
?>
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#669933"><ul>
<?
$query=mysql_query("select * from news where active='active' order by no desc limit 0,20");
// newslerin sadece titlelarini ekranda gosterip link verecegiz
while($row=mysql_fetch_row($query))
{
$no=$row[0];
$title=$row[1];
echo "<li> <a href=index.php?no=$no>$title</a></li>";
}
?>
</ul></td>
</tr>
</table>
</form>
<?
} // end else
?>
<table border="0" cellpadding="5" align="center">
<tr>
<td>Go to the page:</td>
<?php
for ($i = 1; $i < $page_sayi; $i++) {
$txt = $i;
if ($page != $i)
$txt = "<a href=\"" . $_SERVER["PHP_SELF"] . "?page=$i\">$txt</a>";
?>
<td align="center"><?= $txt ?></td>
<?php
}
?>
</tr>
</table>
<hr>
</div>
<?
if ($query) mysql_free_result($query);
if ($rs) mysql_free_result($rs);
if ($connect) mysql_close($connect);
?>
</body>
</html>
as demo you can go here aziko.6te.net/yukle/
Thanks beforehands