我有个问题。我想在页面中显示每个“主题”(标题),而不仅仅是像现在这样的第一个。当我添加一条新消息时,索引只显示第一条消息,只有当我单击“打开”按钮时,我才能看到所有消息。
有什么建议吗?
非常感谢。
这是解码代码:
<?php
require_once("config.php");
if (isset($_SESSION['username']) === FALSE){
header('location:login.php');
exit();
}
$where = "";
$searchCriteria = "";
if (isset($_GET['search']) && $_GET['search'] != '') {
$searchCriteria = mysql_real_escape_string($_GET['search']);
$where = " WHERE subject LIKE '%" . $searchCriteria . "%'";
$where .= " OR message like '%" . $searchCriteria . "%'";
}
$sql = "SELECT * FROM notes " . $where . " LIMIT 30";
$result = mysql_query($sql);
?>
<!DOCTYPE html>
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<a href="logout.php">Logout</a><br/><br/>
<div id="wrapper">
<div id="add-message">
<a href="add.php"><img src="images/add.png" title="Add"> Add a New Message</a>
</div>
<br>
<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<?php echo $row['subject']; ?>
<input type="button" id="opener" value="Open"/>
<div id="playbox">
<table id="general">
<thead>
<tr>
<th class="general-header"></th>
<th class="general-subject">Subject</th>
<th class="general-message">Message</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="general-foot"><input type="button" id="closer" value="Close"/></td>
</tr>
</tfoot>
<tbody>
<tr>
<td>
<a href="edit.php?id=<?php echo $row['id']; ?>"><img src="images/edit.png" title="Edit"> Edit</a>
|
<a href="delete.php?id=<?php echo $row['id']; ?>"><img src="images/delete.png" title="Delete"> Delete</a>
</td>
<td class="subject"><?php echo $row['subject']; ?></td>
<td><?php if ($row['filename']!=''){?>
<img align="right" width="300px" src="<?php echo $row['filename']; ?>" />
<?php } ?>
<?php echo $row['message']; ?>
</td>
</tr>
</tbody>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$("#playbox").hide();
$("#opener").click(function(){
$("#playbox").slideDown(600);
});
$("#closer").click(function(){
$("#playbox").slideUp(600);
});
});
</script>