您的位置:首页 > 编程语言 > PHP开发

PHP+SQLITE制作简单的视频点播程序

2005-07-07 10:19 429 查看
本文介绍怎样利用 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='sql.php'>进入创建数据文件</a>";
    }
    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='sql.php'>该处</a>继续添加";
        }
        else
        {
            echo "数据添加失败,请检查后重试";
        }
    }
?>
  4.  index.php视频点播主界面;

<?php
    $db = sqlite_open("db.sqlite"); //连接数据库
    $sql = "select * from test ";
    $query = sqlite_query($db, $sql); //选出表中数据
?>
<html>
<head>
<title>视频点播</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<table width="100%" border="1">
<tr>
<?php
    while ($res = sqlite_fetch_array($query))
    {
        // show the data
        echo "<td>";
        echo "<a href=red.php?id=" . $res['id'] . ">" . $res['name'] . "</a>";
        echo "</td>";
    }
     
?>
<tr>
</table>
</body>
</html>
  5.show.php视频点播播放界面;

<?php
    $id = $_GET['id']; //取得Id的值
     
    $db = sqlite_open("db.sqlite"); //连接数据库
     
    $sql = "select * from test where id='$id'";
    $query = sqlite_query($db, $sql);
    $res = sqlite_fetch_array($query);//取出符合要求的数据
     
?>
<HTML>
<HEAD>
<TITLE><?php echo $res['movie'] ;?></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
</HEAD>
<BODY bgcolor="#F4FFF4">
<table width="576" height="418" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="62" colspan="3"><img src="vod1.jpg" width="590" height="62"></td>
  </tr>
  <tr>
    <td width="21%"><img src="vod2.jpg" width="130" height="290"></td>
    <td width="55%">
       <object ID=RVOCX classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width=326 height=245>
      <param name="src" value="rtsp://localhost:554/<?php echo $res['url'] ;?>">
      <param name="controls" value="ImageWindow">
      <param name="autostart" value="true">
      <param name="console" value="_master">
      <embed width="326" height="245" src="rtsp://localhost:554/<?php echo $res['url'] ;?>" controls="ImageWindow" console="_master" >
      </embed>
   </object>

   <object ID=RVOCX classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width=326 height=40>
      <param name="controls" value="ControlPanel">
      <param name="console" value="_master">
      <embed width="326" height="40" src="cabin_w_layout.rpm"
             controls="ControlPanel" console="_master" >
      </embed>
   </object></td>
    <td width="24%"><img src="vod4.jpg" width="135" height="289"></td>
  </tr>
  <tr>
    <td colspan="3"><img src="vod3.jpg" width="590" height="66"></td>
  </tr>
</table>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sqlite php query sql url border