I summed up some fart experience
1. After the Ajax post data to the background page, and then to reconnect the database, do not think that the previous session is connected to the
2. In order to deal with the problem of return garbled, I added the header ("content-type:text/html;charset=gb2312"), it can be normal display, and later in the Firefox test, but prompted me to download this page, the Internet searched a lot of information, Get a vague understanding of the Web page code has a syntax error, Firefox for security is not directly displayed but prompted to download, I re-check the statement just now, found that they wrote a "\", it removed the problem after the solution, haha, so encountered such a problem, good check the HTML Tag, after all, Firefox is not as smart as IE.
3. Finally say, do the Web site developer, to be responsible, do not think in IE under the test passed on everything, after all, not everyone with IE, but also have to do more testing under other browsers, so as to show your professional standards
Ajax script:
Copy CodeThe code is as follows:
Call:
Copy CodeThe code is as follows:
Header ("content-type:text/html;charset=gb2312");
$pagesize = 10;
echo $_post[' page ';
$result = mysql_query ("SELECT count (DISTINCT hotelname) from". Tbl_hotels);
$myrow = Mysql_fetch_array ($result);
$numrows = $myrow [0];
$pages =intval ($numrows/$pagesize);
if ($numrows% $pagesize)
$pages + +;
if (Isset ($_post[' page ')) {
$page =intval ($_post[' page ');
}
else{
Set as first page
$page = 1;
}
$first = 1;
$prev = $page-1;
$next = $page +1;
$last = $pages;
Calculate record offset
$offset = $pagesize * ($page-1);
Reads the specified number of records
$result =mysql_query ("Select ' Hotelname ', COUNT (*) from". Tbl_hotels. " GROUP by ' hotelname ' ORDER by id desc limit $offset, $pagesize ");
$num = mysql_num_rows ($result);
while ($row = Mysql_fetch_array ($result, mysql_num)) {
$hotelname [] = $row [0];
$countpeople [] = $row [1];
}
for ($a =0; $a < $num; $a + +)
{
$result =mysql_query ("SELECT count (title) from". Tbl_comments. "Where ' title ' =\" ". $title [$a]." \"");
$row = Mysql_fetch_row ($result);
echo "
\ n "; echo "
\ n"; echo "
\ n "; echo "
\ n "; Rating_bar ($title [$a],5); echo " | \ n "; echo "
$hotelname [$a]\n]; echo " |
\ n "; echo "
\ n "; echo "
| \ n "; echo "
\ n "; echo "Recommended number of people: ($countpeople [$a]) |\n"; echo " mean score: (". $count. ") Tickets) | Number of comments: ()\ n "; echo " |
\ n ";
}
echo "
echo "Border=0>"; echo "
"; echo ""; echo "Section ". $page." Page/Total ". $pages." Page | Total ". $numrows." Bar | "; if ($page >1) echo "Home |"; if ($page >1) echo "prev |"; if ($page < $pages) echo "next page |"; if ($page < $pages) echo "Last"; echo "Go to PagePage"; echo " |
";
http://www.bkjia.com/PHPjc/318828.html www.bkjia.com true http://www.bkjia.com/PHPjc/318828.html techarticle I summed up some fart experience 1. After using the Ajaxpost data to the background page, and then to reconnect the database, do not think that the previous session connected to the 2. In order to handle the return of garbled ask ...