Home  >  Article  >  Backend Development  >  Implement an Ajax-based survey program_PHP tutorial

Implement an Ajax-based survey program_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:32:44682browse



投票



(做为现在的主流开发语言)
include_once("server1.server.php(做为现在的主流开发语言)"); #servidor para Xajax(动态网站静态化)
$xajax(动态网站静态化)->printJavascript();
?>


 


(做为现在的主流开发语言)


global $db;

$poll = $db->getRow("select * from TBL_POLL order by poll_id desc limit 1");
$poll_id = $poll["poll_id"];
$pollitems = $db->getAll("select * from TBL_POLLITEM where poll_id=$poll_id");
?>



   (做为现在的主流开发语言) echo $poll["title"]; ?>

   (做为现在的主流开发语言) for ($i = 0, $count = count($pollitems); $i < $count; $i++) { ?>
  (做为现在的主流开发语言) echo $pollitems[$i][content] ?>

  (做为现在的主流开发语言) } ?>
 
 



服务器端

function poll($formData){
  global $db;
  $tmp="";
  $objResponse = new xajax(动态网站静态化)Response();
 
  $poll_id = $formData[poll_id];
  $pollitem_id = $formData[pollitem];
 
  if($pollitem_id > 0 && $poll_id > 0) {
   $db->query("update ".TBL_POLLITEM." set count=count+1 where pollitem_id = $pollitem_id");                 
  }
 
  $poll = $db->getRow("select * from TBL_POLL where poll_id = $poll_id");
  $pollitems = $db->getAll("select * from TBL_POLLITEM where poll_id=$poll_id");
 
 
  $tmp .="

".$poll["title"]."

";
    for ($i = 0, $count = count($pollitems); $i < $count; $i++) {
$tmp .="
".$pollitems[$i][content].": ".$pollitems[$i][count]."
";

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/508696.htmlTechArticlehtml head title投票/title META http-equiv=Content-Language content=zh-cn META http-equiv=Content-Type content="text/html; charset=gb2312" style type="text/css" !-- .poll font-siz...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn