...

View Full Version : php n mysql



hmvrulz
02-24-2007, 10:40 AM
am writing a guest book for wap

while callig the posts in the guest book
am not able to retrive all .. am able to get only the one with id=3..
i am sure i have missed the loop some where... am not getting it where...

here's the 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", "phpmysql_hmv", "harsha");

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

$get_posts = "select id, name, date_format(entry_date, '%b %e') as post_time from guestbook order by entry_date desc";

$get_posts_res = mysql_query($get_posts,$connection) or die(mysql_error());

// POSTS

if (mysql_num_rows($get_posts_res) < 1) {
// there are no posts
$display_block = "<big><b>No Records Found</b></big><br />
<a href=\"add.php\">Click here to Sign GUEST BOOK</a>";
} else {
// create guestbook posts
while ($post_info = mysql_fetch_array($get_posts_res)) {
$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\"><b>$post_time</b><big>:</big><b>$post_creater</b></a>";
}
}


?>


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

</card>
</wml>



Below u can look at the Mysql... it has so many entries....
http://www.gnuer.com/hmv/wap/retrive.php



CREATE TABLE guestbook (
id INT(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
place VARCHAR(30) NOT NULL,
phone VARCHAR(30) NOT NULL,
email VARCHAR(50) NOT NULL,
message TEXT NOT NULL,
entry_date DATETIME NOT NULL
);

hmvrulz
02-24-2007, 10:46 AM
u can see whts happening here....

http://emulator.tagtag.com/wapemulator.cgi?O__SKIN=S1&wurl=http://www.gnuer.com/hmv/wap/show.php

Nightfire
02-24-2007, 10:58 AM
} else {
$display_block = '';
// create guestbook posts
while ($post_info = mysql_fetch_array($get_posts_res)) {
$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\"><b>$post_time</b><big>:</big><b>$post_creater</b></a>";
}
}

hmvrulz
02-24-2007, 12:02 PM
} else {
$display_block = '';
// create guestbook posts
while ($post_info = mysql_fetch_array($get_posts_res)) {
$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\"><b>$post_time</b><big>:</big><b>$post_creater</b></a>";
}
}


thanx sir it works..... can u tell if how to limit 20 results per page.. wht i need to do....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum