Does anyone knows how to make paging script using php + wml? Please give me the example script.
I've tried this script, but when i click the "next" link, it failed. could you tell me what's wrong with sthis script?
<?
header("Content-type: text/vnd.wap.wml");
echo("<?xml version=\"1.0\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n\n");
?>
<wml>
<template>
<do type="prev" label="Back">
<prev/>
</do>
</template>
<card id="card" title="Hasil">
<p>
<?
include("config_dbase.php");
$konek=mysql_connect($host,$user,$pass);
mysql_select_db($dbase,$konek);
$limit=2;
switch ($q) {
case "nama":
$kriteria="nama_lengkap LIKE '%$form%' OR panggilan LIKE '%$form%'";
break;
case "alamat":
$kriteria="asli LIKE '%$form%' OR kos LIKE '%$form%'";
break;
}
$query="SELECT * FROM dbase WHERE $kriteria ORDER BY nama_lengkap ASC";
$hasil=mysql_query($query);
$jumlah = mysql_num_rows($hasil);
if ($jumlah=='0') {
echo "</p>\n";
echo "<p align=\"center\"><br/>Not Found!.</p><p>\n";
} else {
if (empty($offset)) { $offset=0; }
$results=mysql_query("SELECT * FROM dbase WHERE $kriteria ORDER BY nama_lengkap DESC LIMIT $offset, $limit") or die (mysql_error());
$no=$offset+1;
while($tabel=mysql_fetch_array($results)) {
$id=$tabel["id"];
echo $no." <a href=\"db_profil.wml?id=".$id."\">".$nama."</a><br/>";
$no=$no+1;
}
if ($offset>=1) { $prevoffset=$offset-$limit; echo "<a href=\"?offset=$prevoffset\">Sebelumnya</a>\n"; }
$hal=intval($jumlah/$limit);
if ($jumlah%$limit) { $hal++; }
if (!(($offset/$limit)==($hal-1)) && ($hal!=1))
{ $newoffset=$offset+$limit; echo "<a href=\"?offset=$newoffset\">Selanjutnya</a>\n"; }
}
?>
</p>
</card>
</wml>