0

hi all PHP masters and newbies
i have a question about pagination. this news script displays 4 little images and links at the right side and one large image at the left side. and all the links submitted shows below.
i need let at the page displays 8 news with little images and pagination. for ex i have 100 news let it displays latest 8 of them and other will be enabled by click next or 2 page (pagination simly)
thanks for attention

<?php
	require_once('auth.php');
?>

<!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>Bismillah</title>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<p>
<? 
include("connect.php"); 

include ("image_edit.php"); 
?>

</p>
<p style="font-size:24pt; color:#FF0000;">add news</p>

<hr />
Mesajlar :&nbsp;
<? //

$no=$_POST[no];
$title=$_POST[title];
$subject=$_POST[subject];
$explanation=$_POST[explanation];
$aktif=$_POST[aktif];
$search=$_POST[search];
$show=$_POST[show];

// image ayarlari burada
	$large_image="haber_kucuk"; // open this folder
	$little_image="haber_buyuk"; // give mode chmod 777

	$large_image_en=300;
	$large_image_boy=200;

	$little_image_en=100;
	$little_image_boy=75;
	
	
	
//if ($image)

?>
<?  if ($_POST[delete])
{// if isset delete button
$query=mysql_query("select * from haber where no='$no'");
while($row=mysql_fetch_row($query))
	
	{ @unlink($row[4]); // 
		@unlink($row[5]); // 
	}

if (mysql_query("delete from haber where no='$no'")) echo " deleted";
else echo "not deleted";

}
?>
<? 
if ($_POST[edit])
{
//
$query=mysql_query("select * from haber where no='$no'");
	while($row=mysql_fetch_row($query))
	{ 
	$no2=$row[0];
	$title2=$row[1];
	$subject2=$row[2];
	$explanation2=$row[3];
	$littleimage2=$row[4];
	$image2=$row[5];
	$aktif2=$row[7];
	}
}
?>
<? if($_POST["add"])
{ 
if(strlen($_FILES["image"]["name"])>4)
		{
		$find=$_FILES["image"] ;
		$to_be_finded = array('ç','Ç','ý','Ý','ð','Ð','ü','ö','Þ','þ','Ö','Ü',',',' ','(',')','[',']'); 
		$change  = array('c','C','i','I','g','G','u','o','S','s','O','U','','_','','','',''); 
	
		$_FILES["image"]=str_replace($to_be_finded, $change, $find);
		

		$image = "$haber_large_image_klasor/".$_FILES["image"]["name"]; 	   
		move_uploaded_file($_FILES["image"]["tmp_name"],$image);
		
		$littleimage  = "$haber_little_image_klasor/".$_FILES["image"]["name"];  
		move_uploaded_file($_FILES["image"]["tmp_name"],$littleimage);

		
		// little image resampling
		$icerik = resample($image,$little_image_en,$little_image_boy); 
		$folder  = fopen ($littleimage,"w+"); 
				   fwrite($folder,$icerik); 
				   fclose($folder); 
				   
		// large image resampling
		$icerik = resample($image,$large_image_en,$large_image_boy); 
		$folder  = fopen ($image,"w+"); 
				   fwrite($folder,$icerik); 
				   fclose($folder); 

	
		
		
		
		}


if (!$no)
	{
		
	if (mysql_query("insert into haber values ('','$title','$subject','$explanation','$kucukimage','$image','$aktif')"))
	{echo " changed"; $image="";$littleimage="";}
	else echo "not changed!";
	
	}
else 
{ //
	if ($image) $imageek="image='$image',littleimage='$littleimage'";
	if (mysql_query("update  haber set title='$title',subject='$subject',explanation='$explanation',aktif='$aktif'$imageek where no='$no'"))
	{echo "added"; $image="";$littleimage="";}
	else echo "not added";
	}
}
?>
<hr />

<form id="form1" name="form1" method="post" action="">
News :
  <label>
  <select name="no" id="no">
  <?
  $query=mysql_query("select * from haber order by no desc");
while($row=mysql_fetch_row($query))
{
echo "<option value='$row[0]'>$row[1]</option>";
}
  ?>
    
  </select>
  </label>
  <label>
  <input name="edit" type="submit" id="edit" value="edit" />
  </label>
  <label>
  <input name="delete" type="submit" id="delete"  value="delete" />
  </label>
  <label></label>
</form>
<hr />
<form id="form2" name="form2" method="post" action=""   enctype="multipart/form-data">
  <table width="250" border="1" cellspacing="5" cellpadding="0">
    <tr>
      <td width="80">no 
      <input name="no" type="hidden" value="<? echo $no2; ?>" /></td>
      <td width="100"><label></label>	  </td>
    </tr>
    <tr>
      <td>image
 <? if($littleimage2)
 
{echo "<img src=$littleimage2 align=right><br />";

}
?>
</td>
      <td>   <label>
      <input name="image" type="file" id="image" />
      </label></td>
    </tr>
    <tr>
      <td>title</td>
      <td><input name="title" type="text" id="title" value="<? echo $title2;?>" size="50" /></td>
    </tr>
    <tr>
      <td>subject</td>
      <td><input name="subject" type="text" id="subject" value="<? echo $subject2;?>" size="50" /></td>
    </tr>
    <tr>
      <td>explanation</td>
      <td><label>
        <textarea name="explanation" cols="80" rows="5" id="is"><? echo $explanation2;?></textarea>
      </label></td>
    </tr>
    <tr>
      <td>Aktive</td>
      <td><label>
        <input <?php if ($aktif2=="aktif") {echo "checked=\"checked\"";} ?>  name="aktif" type="radio" value="aktif" checked="checked" />
      aktivate 
      <input <?php if ($aktif2=="pasif") {echo "checked=\"checked\"";} ?>  name="aktif" type="radio" value="pasif" />
      Passivate</label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="add" type="submit" id="add" value="add" />
        <label>
        <input name="search" type="submit" id="search" value="search" />
        <input name="show" type="submit" id="show" value="news show" />
        </label></td>
    </tr>
  </table>
</form>

<p>&nbsp;</p>
<? 
if (($search) || ($show))
{
if ($search)
{
if ($title) $query=mysql_query("select * from haber where title like '%$title%'");
if ($subject) $query=mysql_query("select * from haber where subject like '%$subject%'");
if ($explanation) $query=mysql_query("select * from haber where explanation like '%$explanation%'");
}
 if ($show)
{
$query=mysql_query("select * from haber order by no desc");
}
echo "<table border=1>
<tr>
<td>Edit</td>
<td>delete</td>
<td>No</td>
<td>title</td>
<td>subject</td>
<td>explanation</td>
<td>littleimage</td>
<td>aktive</td>
</tr>";
while($row=mysql_fetch_row($query))
{echo "
<tr><form action=\"\" method=\"post\"><input name=\"no\" type=\"hidden\" value=\"$row[0]\">

<td><input name=\"edit\" type=\"submit\" value=\"change\">	</td>
<td><input name=\"delete\" type=\"submit\" value=\"delete\"></td>

<td>$row[0]&nbsp;</td>
<td>$row[1]&nbsp;</td>
<td>$row[2]&nbsp;</td>
<td>$row[3]&nbsp;</td>
<td><img src=$row[4]>&nbsp;</td>
<td>$row[6]</td>
</form>	</tr>";
}
echo "</table>";
}
?>
<?php
echo "<a href=\"http://aziko.6te.net\"> return to the main page</a>";
?>
</body>
</html>
2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by azegurb
0

You should look into mysql's LIMIT for pagination. It is really easy to implement.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.