...

View Full Version : pagination help.... second page prob



hmvrulz
03-04-2007, 02:11 PM
below is the my code for showing posts from a guest book with help of pagination.... when i click the next page link it gives error


Parser failed. Invalid XML syntax.
not well-formed (invalid token) at line 7, column 346, byte 479
Click here to see the wml source

u can see the page here

http://www.wapsilon.com/sourceview.cgi?http://www.gnuer.com/hmv/wap/show1.php?page=2

well heres my php code.....


<? header("Content-Type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?>

<?php

//open connection
$connection = mysql_connect("192.168.2.7", "***", "***");

// Using the database
mysql_select_db("phpmysql_guestbook",$connection);


// If current page number, use it
// if not, set one!

if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}

// Define the number of results per page
$max_results = 25;

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);

// Perform MySQL query on only the current page number's results

$sql = mysql_query("SELECT id, name, date_format(entry_date, '%b %e') as post_time from guestbook ORDER by entry_date desc LIMIT $from, $max_results");

while($post_info = mysql_fetch_array($sql)){
// Build your formatted results here.

$post_id = $post_info['id'];
$post_creater = stripslashes($post_info['name']);
$post_time = $post_info['post_time'];

$display_block .= "<a href=\"post.php?id=$post_id\">$post_time <big>:</big> $post_creater</a><br />";
// end for output
}

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM guestbook"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}


// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}

?>


<wml>
<card>
<?php echo $display_block; ?>

</card>
</wml>

Inigoesdr
03-04-2007, 03:38 PM
Try using
&laquo; and
&raquo; for your left and right double-arrows.

hmvrulz
03-04-2007, 05:37 PM
Try using
&laquo; and
&raquo; for your left and right double-arrows.


til today i was ignoring why the hell we need to use tht kinda codes for simple key strokes... now i learned my lesson.,

thanx mate..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum