2012-10-08 3 views
-1

저는 작은 소셜 네트워크 프로젝트를 진행하고 있습니다. 지금까지 나는 잘 작동하는 메시지 시스템을 가지고 있으며, 사용자는 메시지를 보내고받을 수 있습니다. 사용자가 자신의 메시지를 삭제할 수있는 방법을 찾고 있습니다.텍스트를 클릭하면 MYSQL에서 값이 변경됩니까?

'delete'행이 echo 명령을 통해 각 메시지의 측면을 표시하도록 설정되었습니다. 이 텍스트를 클릭 할 수있게하여 사용자가 클릭 할 때 데이터베이스의 값을 '0'에서 '1'로 변경하도록 할 수 있습니까?

코드 : 서버 측에서 적절한 조치를 트리거 할

<?php 
$page_title = "Messages"; 
include('includes/header.php');  
confirm_logged_in(); 
include('includes/mod_login/login_form.php'); 
?> 

<div class="modtitle"> 
    <div class="modtitle-text">Inbox</div> 
</div> 

<div class="modcontent"> 

<strong>Inbox</strong> | <a href="messages_sent.php">Sent Messages</a> 
| <a href="messages_deleted.php">Deleted</a> <br /><br /> 
<table 
width="100%" border="0" cellpadding="5" cellspacing="0"> 
<tr 
bgcolor="#CCCCCC"> 
    <td width="30%"><strong>Recieved</strong></td> 
    <td width="20%"><strong>From</strong></td> 
    <td width="28%"><strong>Subject</strong></td> 
    <td width="0%"><strong>Read/Unread</strong></td> 
    <td width="0%"><strong>Delete</strong></td> 
</tr> 


<?php 
    $inbox_set = get_inbox(); 
    while ($inbox = 
mysql_fetch_array($inbox_set)) { 
      ?> 

<?php if ($inbox['read'] == 0) { ?> <tr bgcolor="#6666B3"> <?php } 
if ($inbox['read'] == 1) { ?> <tr> 

<?php } ?> 



    <td><?php 

      $datesent1 = $inbox['date_sent']; 
      echo "$datesent1"; ?></td> 


    <a href="profile.php?id={$inbox['from_user_id']}"><td><?php echo "<a 
href=\"profile.php?id={$inbox['from_user_id']}\">{$inbox['display_name']}"; 
?></td></a> 

    <td><?php echo "<strong><a href=\"read_message.php?msg={$inbox[0]}\">{$inbox['subject']}</a></strong>"; 
?></td> 

    <td><?php if ($inbox['read'] == 0) { 
       echo "Unread"; 
       } 
       if ($inbox['read'] == 1) { 
       echo "Read"; 
       } 
       ?></td> 
       <td> 
       <?php 
       if ($inbox['delete'] == 0) { 
       echo "Delete"; 


       } 
       if ($inbox['delete'] == 1) { 
       echo "$deleted_set;"; 
       } 


        ; ?></td> 


       </td> 
     <?php } 


?> 

</tr> </table> 



</div> 

<?php include('includes/footer.php'); ?> 
+0

같은 유사한이 작업을 수행하므로 아약스 ILE에 정보를 전송하고 메시지를 삭제할 수 있습니다 onsucces합니다. – JonathanRomer

+1

Ajax를 사용하려고 시도합니다. – Codesen

+0

훌륭한 샘플이 여기에 있습니다. http://www.w3schools.com/php/php_ajax_database.asp –

답변

0

를 사용하여 AJAX 요청.

그렇지 않으면 다른 사용자가 소유 한 메시지를 삭제할 수 있습니다.

0

사용 jQuery를 + 아약스 내가 아약스와 함께이 일을 권하고 싶습니다이

$.ajax({ 
     type:"POST", 
     url: url, // action page url 
     data: "id="+id, 
     success: function(msg){ 
     if(msg) { 
       //action here  
     } 
    }); 
관련 문제