my paging task with PHP does not work. It uses cookie.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear my friends...

I am trying to display the content of a table. Each page must content only 5 records maximum. Each page has "Previous" and "Next" buttons (made from anchor).

I dump the primary of the working table and keep it in a cookie. So than the paging task work with the index of cookie array. But the $curguruescomidiklan stays "0" each time I click "Next" button.

The main part of doing the paging task is this lines:
"
for ($it=$curguruescomidiklan;$it<$itot;$it++){
	$idad=$guruescomidiklan[$it];
	echo "idad= $idad<br>";
	echo "it: $it<br>";
	bukaiklan($idad);
}
".

Please tell me why PHP does not work as I expect.

Thank you very much in advance.
=====
<html>
<?php
session_start();
session_register("tiket");
setcookie("curguruescomidiklan");
setcookie("guruescomidiklan","");
setcookie("jmli");
$tiket=session_id();
$pageamount = 5;
?>

<table align="center">
<tr>
<!--Bagian Pencari Kerja-->
<td valign="top" background="gambar/gbkiri.gif">
<table align="right" border=0 cellpadding=0 cellspacing=0 width=300>
<tr>
	<td align="left">
	<table border=1 cellpadding=0 cellspacing=0>
<?php
if ($curguruescomidiklan>0){ echo "<tr><td><a href=\"index.php?p=t\" style=\"text-decoration:none;\">Previous</a></td></tr>"; }
?>
	</table>
	</td>
	<td></td>
	<td align="right">
	<table border=1 cellpadding=0 cellspacing=0>
		<tr><td>
<?php
if (($jmli % $curguruescomidiklan)>1 or $curguruescomidiklan==0){ 
	echo "<a href=\"index.php?p=n\" style=\"text-decoration:none;\">Next</a></td></tr>"; 
}
?>
		</td></tr>
	</table>
	</td>
</tr>
<tr><td>
<?php
echo "<tr><th colspan=12>Lowongan Kerja</th></tr>";
include_once "koneksi.php";
$sqlnya="
	select l.id_iklan 
	from perusahaan as p right join lowongan as l on l.id_account=p.id_account 
	where l.lama_tayang >= (current_date-l.mulai_tayang) 
	order by bid desc
	";
$kelas=new koneksi();
$klas=$kelas->getkoneksi("headhunter",$sqlnya);
$jmli=mysql_num_rows($klas);
if ( $jmli > 0 ) {
$i=0;
while(list($idiklan)=mysql_fetch_row($klas)) {
//	echo "ID Iklannya: $idiklan<br>";
	setcookie("guruescomidiklan[$i]","$idiklan");
	$i++;
}
} else {
	echo "No Ad of job vacancy currently in our database<br>";
}
if (empty($curguruescomidiklan)){
	$curguruescomidiklan=0;
}
//echo "pa: $pageamount<br>";
if (isset($p)){ $nt=$_GET['p']; }
//I meant this part should direct the page content to be the next array contents
if ($jmli>=$pageamount){
	echo "curguruescomidiklan -->$curguruescomidiklan<br>";
	if ($nt=='t'){
		$itot=$_COOKIE['curguruescomidiklan']-$pageamount;
	}else{
		$itot=$_COOKIE['curguruescomidiklan']+$pageamount;
		echo "lewat sini $curguruescomidiklan $pageamount<br>";
	}
	echo "itot 1 -->$itot<br>";
}else{
	$itot=$jmltot;
	echo "itot 2 -->$itot<br>";
}
for ($it=$curguruescomidiklan;$it<$itot;$it++){
	$idad=$guruescomidiklan[$it];
	echo "idad= $idad<br>";
	echo "it: $it<br>";
	bukaiklan($idad);
}
$itot=$itot+$pageamount;
setcookie("curguruescomidiklan","$itot");
echo "curguruescomidiklan--> $curguruescomidiklan<br>";

function bukaiklan($myid){
//echo "myid=$myid<br>";
$sqlnya="
	select p.company_fullname, p.company_address, p.city, p.country, p.postcode, p.phone, p.fax, p.url, p.company_description, l.iklan, l.id_iklan 
	from perusahaan as p right join lowongan as l on l.id_account=p.id_account 
	where l.lama_tayang >= (current_date-l.mulai_tayang) and 
		l.id_iklan='$myid'
	order by bid desc
	";
$kelassqlbukaiklan=new koneksi();
$klassqlbukaiklan=$kelassqlbukaiklan->getkoneksi("headhunter",$sqlnya);
if ( mysql_num_rows($klassqlbukaiklan) > 0 ) {
while(list($namaprsh, $alamat, $kota, $negara, $kodepos, $telfon, $faks, $url, $comdesc, $iklan, $idiklan)=mysql_fetch_row($klassqlbukaiklan)) {
	echo "<tr><td valign=\"top\">Employer</td><td valign=\"top\">:</td><td valign=\"top\" colspan=10>$namaprsh</td></tr>";
	echo "<tr><td valign=\"top\">Address</td><td valign=\"top\">:</td><td valign=\"top\" colspan=10>$alamat</td></tr>";
	echo "<tr><td valign=\"top\">City</td><td valign=\"top\">:</td><td valign=\"top\" colspan=10>$kota</td></tr>";
	echo "<tr><td valign=\"top\">Country</td><td valign=\"top\">:</td><td valign=\"top\" colspan=10>$negara</td></tr>";
	echo "<tr><td valign=\"top\">Postcode</td><td valign=\"top\">:</td><td colspan=10 valign=\"top\">$kodepos</td></tr>";
	echo "<tr><td valign=\"top\">Fax</td><td valign=\"top\">:</td><td valign=\"top\" colspan=10>$faks</td></tr>";
	echo "<tr><td valign=\"top\">Website</td><td valign=\"top\">:</td><td colspan=10 valign=\"top\">$url</td></tr>";
	echo "<tr><td valign=\"top\">Business Field</td><td valign=\"bottom\">:</td><td valign=\"bottom\" colspan=10>$comdesc</td></tr>";
	echo "<tr><td colspan=12>$iklan</td></tr>";
	echo "<tr><td colspan=12 height=16></td></tr>";
}
} else {
		echo "No Ad of job vacancy currently in our database, possibly ads-id wrong.<br>";
	}
}

?>
</td></tr></table>
</td>


<!--Bagian Toko Buku Guru-->
<td valign="top">
</td>


<!--Bagian Employer-->
<td valign="top">
</td>
</tr>
</table>
</body>
</html>

-- 
Patrik Hasibuan <patrikh@xxxxxxxxxxxxxxxxxxxxx>
Junior Programmer

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux