留言板php数据库设计 留言板的数据库设计( 二 )


if($cutleng$strleng)return $str;//字符串长度小于规定字数时,返回字符串本身
$notchinanum = 0; //初始不是汉字的字符数
for($i=0;$i$cutleng;$i++)
{
if(ord(substr($str,$i,1))=128)
{
$notchinanum++;
}
}
if(($cutleng%2==1)($notchinanum%2==0)) //如果要截取奇数个字符,所要截取长度范围内的字符必须含奇数个非汉字,否则截取的长度加一
{
$cutleng++;
}
if(($cutleng%2==0)($notchinanum%2==1)) //如果要截取偶数个字符,所要截取长度范围内的字符必须含偶数个非汉字,否则截取的长度加一
{
$cutleng++;
}
return substr($str,0,$cutleng);
}
?
html
head
script type="text/javascript"
function All(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; iaa.length; i++)
aa[i].checked = e.checked; //得到那个总控的复选框的选中状态
}
function Item(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; iaa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
/script
/head
?php
include("conn.php");
if(isset($_POST['del']))
{
$mm = $_POST["selected"];
$id =implode(",",$mm);
$sql = "delete from forums where id in(".$id.")";
//echo $sql;
$result=mysql_query($sql);
echo $result?"删除成功":"删除失败";
}
?
table style="BORDER-BOTTOM-WIDTH: 1px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=600 align=center border=1 bordercolor=#ddddff
tralign=middle
td height=40 bgColor=#DFFFDF colspan=3论坛列表/td
/tr
tr
td colspan=3a href="https://www.04ip.com/post/login.php" style="float:right"[退出系统]/aa href="https://www.04ip.com/post/add_forum.php" style="float:right"[添加论坛]/a/td
td/td
/tr
tralign=middle
td height=40 bgColor=#DFFFDF width=80状态/td
td height=40 bgColor=#DFFFDF论坛/td
td height=40 bgColor=#DFFFDF最后更新/td
/tr
?php
$sql="select * from forums";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num0)
{
while($row=mysql_fetch_array($result)){
?
tr align=middle
td bgColor=#fffbecinput type="checkbox" name="selected" value="https://www.04ip.com/post/1"//td
td height=50 bgColor=#fffbec width=300
?php
echo "diva href=https://www.04ip.com/"forums.php?F=".$row['ID']."\"".$row['forum_name']."/a/div";
echo cutstr($row['forum_description'],24);//最多显示24个字节,12个字,多余部分用省略号代替
echo "……";
?
/td
td height=50 bgColor=#fffbecdiv?php echo $row['last_post_time']."by".$row['last_post_author']?/div/td
/tr
?php
}
}
else
{
echo "tr bgColor=#fffbectd colspan=3对不起,论坛尚在创建中……/td/tr";
}
?
tr
td colspan=3input type="checkbox" name="selected" value="https://www.04ip.com/post/1" onclick="All(this,'selected')"/全选/不全选/td
/tr
tr
tdinput type="button" name="del" id="del" value="https://www.04ip.com/post/删除选中项"/
?php
?
/td
/tr
/table
/html
自己创建数据库就好 。
求一步一步教PHP留言板制作方法1. 先设计数据表,一般留言板需要两个表:留言内容表、回复表
留言内容表:messages
字段如下:
id 自动增加
contents 留言内容
messages_time 留言时间
回复表:reply
字段如下:
id 自动增加
messages_id 关联messages表的id

推荐阅读