最新下载
热门教程
- 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) {
相关文章
- Tplink企业版路由器WiFi名称的默认设置介绍(Tplink企业版路由器WiFi名称的默认设置是什么) 09-06
- Tplink路由器灯常亮无法上网的原因分析(如何解决Tplink路由器灯常亮无法上网的问题) 09-06
- Tplink千兆企业级路由器自动重启的作用和优势介绍(如何设置Tplink千兆企业级路由器自动重启功能) 09-06
- 一根天线的tplink路由器有哪些(一根天线的Tplink路由器的特点和优势介绍) 09-06
- tplink路由器外网访问不了nas(Tplink路由器外网访问NAS的原因分析) 09-06
- Tplink无法搜到路由器的原因分析(如何解决Tplink无法搜到路由器的问题) 09-06