答案:本文介绍怎样利用 PHP SQLITE 制作简单的视频点播程序,这是一个简单的视频点播程序,设有过多的美观界面。下面介绍一下程序文件的功能:
1. init.php初始化数据库,及表文件;<?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=>;
}
else
{
echo "数据初始化失败,请重试!";
}
?>2.form.php提供数据输入的表单;
<form name="form1" method="post" action="add.php">
<table width="48%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="36%" height="38"><div align="right">影片名称:</div></td>
<td width="64%"> <input type="text" name="movie"> </td>
</tr>
<tr>
<td height="39"><div align="right">影片地址:</div></td>
<td><input type="text" name="url"></td>
</tr>
<tr>
<td height="33"><div align="right">影片简介:</div></td>
<td><textarea name="content"></textarea></td>
</tr>
<tr>
<td height="53" colspan="2"><div align="center">
<input type="submit" name="Submit" value="确 定">
<input type="reset" value="重 填">
</div></td>
</tr>
</table>
</form>3.add.php添加表数据;
<?php
$movie = $_POST['movie'];
$url = $_POST['url'];
$content = $_POST['content'];
$now = date("Y- m- d H:i:s");
if (trim($movie) == "" || trim($url) == "" || trim($content) == "")
{
echo "请填写完整数据再提交!";
exit();
}
else
{
$db = sqlite_open("db.sqlite");
$sql = "insert into test (movie,url,content,time) values ( '$movie','$url','$content','$now')";
$result = sqlite_query($db, $sql);
if ($result)
{
echo "数据添加成功";
echo "点击<a href=>;
}
else
{
echo "数据添加失败,请检查后重试";
}
}
?>4. index.php视频点播主界面;
<?php
$db = sqlite_open("db.sqlite"); //连接数据库
$sql = "select * from test ";
$query = sqlite_query($db, $sql); //选出表中数据
?>
- 更多SQLite疑问解答:
- 数据库sqlite3 里:用函数sqlite3_get_table来获取数据是否 可以 排序么(order by cTime asc)
- 开始学sqlite,在下载了个sqlite3_exe,和一个sqlite admin数据库,我现在疑问的是,可以通过sqlite3.exe
- 关于Sqlite使用Group by以后的排序问题。
- sqlite做网络数据库怎么样
- sqlite支持动态sQL,能不能给个对表名进行拼接的,可以运行通的过的代码范例啊,大侠们
- 用SQLite expert创建的数据库,如何导入到android中
- sqlite3 开始建立数据库时,没有设定主键。怎么去修改
- Android中用SQLite数据库是出现的错误,帮忙解决一下:
- android 应用程序开发用到数据库 ,是否需要使用SQLite Manager
- sqlite查询条件参数为空怎么办
- Android sqlite通过字符串为条件执行删除某一记录的问题
- android 程序碰到问题,很简单的一个程序,从sqlite数据库里面查找数据,点击按钮后获得相应数据
- sqlite数据库中插入数据时出现database is locked!什么原因?我没有设置密码.
- ios移动开发、QT应用开发、ZigBee协议栈、SQlite数据库支持,这些都可以描述成我应用到的技术吗?
- sqlite和mysql有关系吗? 能代替mysql运行织梦程序吗?