db = cs4_open(); //レコードの有無を確認 $where = sprintf(" post_id = %s ",$id); $ret = cs4_select($this->db,"tonari_vote",$where); while($row = cs4_fetch_row($ret)){ $poll = $row['poll']; $flg = "true"; } if($flg == "true"){ $int = $poll + 1; $data = array( "post_id" => $id, "poll" => $int, ); $where = sprintf(" post_id = %s ",$id); $result = cs4_select($this->db,"tonari_vote",$where); while($row2 = cs4_fetch_row($result)){ $uniq_id = $row2['uniq_id']; } //DBに格納 $ret_update = cs4_update($this->db,"tonari_vote",$data,$uniq_id); }else{ $int = 1; $data = array( "post_id" => $id, "poll" => $int, ); //DBに格納 $ret_insert = cs4_insert($this->db,"tonari_vote",$data); } // テンプレート読み込み $template =& loadTemplate( $p ); //テンプレートの設定 if($ret_insert || $ret_update){ $template->setCurrentBlock('__Regist__'); $template->setVariable('user_name',$user_name); $template->setVariable('title',$title); $template->parseCurrentBlock(); }else{ $template->touchBlock('__ShowError__'); $template->hideBlock('__Regist__'); } //- コンテンツトップ戻りリンク $template->setVariable('contents_top_url','tonari_top.php'); $template->setVariable('contents_top',TONARI_NAME); //テンプレート表示 $template->show(); //DB開放 cs4_close($this->db); } tonari_good( $p ); ?>