最新下载
热门教程
- 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) {
相关文章
- 沙石镇时光肥料怎么合成-详细方法介绍 05-05
- 新版cex交易所app 05-05
- cex数字货币交易所 05-05
- pi币挖矿app2024最新版本 05-05
- cex交易平台app下载2024最新版 05-05
- 火必网app官网正版 05-05