这是从数据库中获取记录的PHP代码:
<?php
include("dbconn.inc");
$data = mysql_query(
"SELECT `subtitle`, `mian-title`, `page_num`, `note_path`, `flash_path`
FROM `main-page`
WHERE `page_num` =".$r." LIMIT 1";
echo $data;
if (mysql_num_rows($data) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($data)) {
echo $row['page_num'];
}
include("close.php");
?>
这是 HTML:
<form method="post" action="data.php">
<input name="Button1" type="submit" value="<<" />
<input name="test" style="width: 31px; height: 23px" type="text" /> // this is a value of page_num in DB.
<input name="Button2" type="submit" value=">>" >
</form>
我想添加 Ajax 代码以从 PHP 代码中检索记录,然后根据返回的数据更改输入值,并且还想防止页面刷新!