笑话内容管理系统的实现与操作
1. 引言
在开发一个笑话内容管理系统时,我们需要实现添加、编辑和删除笑话等功能。本文将详细介绍如何通过PHP代码实现这些功能,包括创建表单、处理表单提交以及与数据库交互等操作。
2. 添加笑话
在添加笑话的功能中,我们主要使用 newjoke.php 文件。这个页面与 newauthor.php 和 newcat.php 类似,但增加了为笑话指定作者和类别的功能。
2.1 表单代码
首先,我们需要从数据库中获取所有作者和类别的列表:
<?php
else: // Allow the user to enter a new joke
$authors = @mysql_query('SELECT id, name FROM author');
if (!$authors) {
exit(
'<p>Unable to obtain author list from the database.</p>');
}
$cats = @mysql_query('SELECT id, name FROM category');
if (!$cats) {
exit('<p>Unable to obtain category list from the ' .
'database.</p>');
}
?>
</
超级会员免费看
订阅专栏 解锁全文
9035

被折叠的 条评论
为什么被折叠?



