SQL CREATE TABLE 语法 CREATE TABLE 表名称 ( 列名称1 数据类型, 列名称2 数据类型, 列名称3 数据类型, .... )
<span style="font-family:Comic Sans MS;font-size:14px;"><?php
include("head.php");
$dbName = "bbs";
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
$flag = mysql_select_db($dbName, $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
function toHtmlcode($content)
{
return $content = str_replace("n","<br>",str_replace(" ", " ", $content));
}
?></span>
| 参数 | 描述 |
|---|---|
| find | 必需。规定要查找的值。 |
| replace | 必需。规定替换 [i]find[/i] 中的值的值。 |
| string | 必需。规定被搜索的字符串。 |
| count | 可选。一个变量,对替换数进行计数。 |
<span style="font-family:Comic Sans MS;font-size:14px;"><?php
// 引用之前写好的连接数据库文件
include("conn.php");
if(@$_POST['submit']){
$sql = "insert into message (id,user,title,content,lastdate)" .
"values ( '','$_POST[userName]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "添加成功";
}
?>
<SCRIPT language=javascript>
function CheckPost()
{
if (myform.userName.value=="")
{
alert("请填写用户名");
myform.user.focus();
return false;
}
if (myform.title.value.length<5)
{
alert("标题不能少于5个字符");
myform.title.focus();
return false;
}
if (myform.content.value=="")
{
alert("必须要填写留言内容");
myform.content.focus();
return false;
}
}
</SCRIPT>
<form action="addmsg.php" method="post" name = "myform" onsubmit="return CheckPost();">
用名:<input type="text" size="10" name="userName" /><br/>
标题:<input type="text" name="title" /><br/>
内容:<textarea name="content" cols="60" rows="9" ></textarea><br/>
<input type="submit" name="submit" value="提交留言" />
</form>
</span>
<span style="font-family:Comic Sans MS;font-size:14px;"><?php
include("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$sql = "SELECT * FROM message order by lastdate desc";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td><b><big>
标题:<?= $row['title']?></big><b/> <b><sub>
用户:<?= $row['user']?></sub></b></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?= toHtmlcode($row['content'])?></td>
</tr>
<?php
}
?>
</table>
</span>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有