search
Homephp教程php手册超级简单的php+mysql留言本源码

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

Jun 13, 2016 pm 12:20 PM
index.phpphp+mysqldatabasedocumentSource codeofSimpleconnect

共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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.