如果我们要在我们的info数据库中建立articles表,其中articles表的sql定义如下所示:
create table if not exists articles
(
   article_id  int not null auto_increment,
   artilce_author  varchar(20)  not null default ‘admin’,
   articlecontent_id int,
  article_datetime datetime not null default ’0000-00-00 00:00:00′,
  article_content text,
  primary key (article_id)
);

  实现在info数据库中自动产生该表的php代码如下:
解释:IP—数据库的ip地址
<?php 
 $id=mysql_connect(“IP”,”user”,”password”);//链接数据库
 if(mysql_select_db(“info”,$id))//选择info数据库成功
{
$sql=”*****”;//上面articles表的sql定义语句
$isok=myslql_query($sql);//执行sql语句,在info数据库中建立articles表
if($isok==true)
{
echo “建立articles表成功”;
}
else
{
echo “建立articles表失败”;
}
}
else
{
die  ”选择info数据库失败,程序停止执行!”;
}
?>

  到此为止我们的网站自动安装的功能介绍完毕,数据库中的其它的表也可以采用相同的操作来实现自动建立。

  在这我们也可以通过同样的思想实现网站的自动卸载,比如如果你哪天不想使用WordPress了,如果你仅仅是把虚拟主机中的相关文件删掉的话,那还不是完全的卸载,毕竟你的数据库中的表没有删除掉,而那些表是要占据空间的。

  下次我们来介绍网站的自动卸载功能!



相关文章:

  1. 获得任一页面的链接和地址!
  2. 网站自动安装之三!
  3. php中global变量的使用说明!