SQLiteManager版本1.2.0安装下载地址:http://down.chinaz.com/soft/23673.htm
1. 创立一个php100.db的数据库
<?php
$db=sqlite_open("php100.db");
$sql="create table test (id INTEGER PRIMARY KEY,content text,time datatime)";
$result=sqlite_query($db,$sql);
?>
2.从php100.db数据库中查询数据并输出
<?php
$db=sqlite_open("php100.db");
$sql="select * from test";
$result=sqlite_query($db,$sql);
$row=sqlite_fetch_array($result);
print_r($row);
?>
3. 一套完整的sqlite 使用代码
<?php
$db = sqlite_open("db.sqlite"); //创建并连接数据库
$sql = "create table test (id INTEGER PRIMARY KEY,movie text,url text,content text ,time datatime)"; //创建表
$result = sqlite_query($db, $sql);
if ($result)
{
echo "数据初始化成功";
echo "<a href='sql.php'>进入创建数据文件</a>";
}
else
{
echo "数据初始化失败,请重试!";
}
?>
4. 数据库语句的实例练习
<?php
$db=sqlite_open("php100.db",0666,$sqlite_error);
if($_POST[submit]){
$sql="insert into test (id,content,time) values (NULL,'$_POST[content]','$_POST[time]')";
sqlite_query($db,$sql);
//echo sqlite_last_insert_rowid($db);
}
$sql="select * from test order by id DESC";
$query=sqlite_query($db,$sql);
while($row=sqlite_fetch_array($query)){
echo "标题:$row[content]--年份:$row[time]<hr/>";
}
?>
<form action="" method="post">
标题:<input type="text" name="content"/><br/>
年份:<input type="text" name="time"/><br/>
<input type="submit" name="submit" value="发布内容"/><br/>
</form>