저는 작은 소셜 네트워크 프로젝트를 진행하고 있습니다. 지금까지 나는 잘 작동하는 메시지 시스템을 가지고 있으며, 사용자는 메시지를 보내고받을 수 있습니다. 사용자가 자신의 메시지를 삭제할 수있는 방법을 찾고 있습니다.텍스트를 클릭하면 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'); ?>
같은 유사한이 작업을 수행하므로 아약스 ILE에 정보를 전송하고 메시지를 삭제할 수 있습니다 onsucces합니다. – JonathanRomer
Ajax를 사용하려고 시도합니다. – Codesen
훌륭한 샘플이 여기에 있습니다. http://www.w3schools.com/php/php_ajax_database.asp –