Home  >  Article  >  Backend Development  >  超级简单的php+mysql留言本源码_php实例

超级简单的php+mysql留言本源码_php实例

WBOY
WBOYOriginal
2016-06-07 17:26:07786browse

共3个文件
IncDB.php数据库连接
index.php首页
InsetToDB.php数据库操作
数据库lguestbook里面建表

复制代码 代码如下:

CREATE TABLE `intd` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) character set utf8 collate utf8_bin NOT NULL,
`text` text character set utf8 collate utf8_bin NOT NULL,
`datetime` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312 AUTO_INCREMENT=11 ; //此句参考下面的扩展内容;

IncDB.php数据库连接
复制代码 代码如下:

$link=mysql_connect('localhost','root','root');
if(!$link)
{
die("
出错啦:1!
");
}
if(!mysql_select_db('guestbook',$link))
{
die("
出错啦:2!
");
}
?>

index.php代码
复制代码 代码如下:


include("IncDB.php");
$result=mysql_query("SELECT * FROM intd",$link);
$row=mysql_fetch_row($result);
while($row)
{
echo "ID: ".$row[0]." 濮撳悕: ".$row[1]." 鏃堕棿: ".$row[3]."
";
echo $row[2];
echo "

";
$row=mysql_fetch_row($result);
}
mysql_close($link);
?>

鏄电О:

鍐呭

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn