最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用PHP和MySQL构建一个数据库驱动的网站(7)
时间:2022-07-02 10:31:03 编辑:袖梨 来源:一聚教程网
现在我们已经有了允许用户输入一个笑话并将其加入到我们的数据库中的程序代码。现在剩下的就是将其加入到我们已做好的笑话显示页面。因为绝大多数的用户只会想要看看笑话,所以我们不想对我们的页面做大的更改,除非用户表示想要添加一个新的笑话。因为这个原因,我们的应用程序应该是一个多功能的页面。下面是程序的代码:
>
...
// If the user wants to add a joke
if (isset($addjoke)):
?>
else:
// Connect to the database server
$dbcnx = @mysql_connect("localhost",
"root", "mypasswd");
if (!$dbcnx) {
echo( "
exit();
}
// Select the jokes database
if (! @mysql_select_db("jokes") ) {
echo( "
exit();
}
// If a joke has been submitted,
// add it to the database.
if ("SUBMIT" == $submitjoke) {
>
...
// If the user wants to add a joke
if (isset($addjoke)):
?>
else:
// Connect to the database server
$dbcnx = @mysql_connect("localhost",
"root", "mypasswd");
if (!$dbcnx) {
echo( "
Unable to connect to the " .
"database server at this time.
exit();
}
// Select the jokes database
if (! @mysql_select_db("jokes") ) {
echo( "
Unable to locate the joke " .
"database at this time.
exit();
}
// If a joke has been submitted,
// add it to the database.
if ("SUBMIT" == $submitjoke) {
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16