2013-06-15 2 views
0

나는 내 프로젝트를위한 알림 시스템을 구축하고 있는데, 내가 원하는 것은 사용자가 알림 링크 (예 : [3])를 클릭하면 3 개가 있음을 의미합니다. 읽지 않은 알림, 내가 원하는 것은 사용자가 클릭하여 알림 테이블을 업데이트하고 볼 필드를 1로 설정하여 알림 링크가 [0]이 될 것이고 이것이 아약스 요청 또는 기타를 통해 얻을 수 있음을 알 때입니다. 방법 도움이 될 수 있습니다 사람이 내 프로젝트를 마무리 많은 사촌의 m를 감사하고 여기에 z를 내 코드 :-) 시간이 실행될 경우Codeigniter 쿼리 (업데이트) 데이터베이스 onclick

  <?php if (isset($this->session->userdata['messagecount'])): ?> 
       <?php if (empty($this->session->userdata['messagecount'])){echo "<button class='btn'></button>";}else{ 

        $count=$this->session->userdata['messagecount']; 

    echo "<button class='btn btn-info dropdown-toggle notify-btn' data-toggle='dropdown' onclick='updateNotifications()'href='#'>".$count."</button>"; 
        }?> 


    <?php endif; ?> 

     <ul class="dropdown-menu"> 
     <div class="notify-wrapper"> 
      <div class="scroll"> 
      <div class="scroll-body"> 
       <ul class="notification-list"> 
      <?php if (isset($this->session->userdata['notification'])): ?> 
       <?php if (empty($this->session->userdata['notification'])){echo "No Notifications";}else{ 

        $notification=$this->session->userdata['notification']; 

        echo $notification; 
        }?> 


    <?php endif; ?> 
      </ul> 
      </div> 
      </div> 
      </div> 
     </ul> 


    <?php }else{?> 



    <?php }?> 
</li> 

답변

0

당신의 요구 사항에 따라이 더러운 코드 변경을 시도해보십시오

<div id="notification_counter"><?php echo $note; ?></div> 
<div id="notification_container"> 
     <ul> 
       <li class= "notification_heading" onClick="read_notification_url">one</li> 
       <li class= "notification_heading" onClick="read_notification_url">two</li> 
       <li class= "notification_heading" onClick="read_notification_url">three</li>     
     </ul> 
</div> 

<script> 
$(function() { 
     $(".notification_heading").click(function(){ 
       var rquest = $.ajax({ 
          type: "POST", 
          url: "url_to_modify_counter", 
          }); 
          rquest.done(function(msg) {        
           $('#notification_counter').val($('#notification_counter').val()-1); 
           } 
       }); 
      }); 
</script> 

것은 만들기 위해 반드시 그것을 안전하고 데이터 형식 변환 및 모든 보안 검사

관련 문제