我有一个视频播放器,想要从mysql数据库填充视频,这是我的代码。
<ul id="playlist1" style="display:none;">
<li data-thumb-source="assets/img/ddd.jpg" data-video-source="assets/video/ddd.mp4" data-poster-source="assets/img/ddd.jpg" data-downloadable="yes">
<div data-video-short-description="">
<div>
<p class="minimalDarkThumbnailTitle">ddd</p>
<p class="minimalDarkThumbnailDesc">dddd.</p>
</div>
</div>
<div data-video-long-description="">
<div>
<p class="minimalDarkVideoTitleDesc">dddd</p>
<p class="minimalDarkVideoMainDesc">ddd</p>
<p>For more information about this please follow <a href="#" target="_blank">this link</a></p>
</div>
</div>
</li>
</ul>
我的MySQL数据库包含以下列
我的PHP代码从数据库中获取数据:
<?php
$result= mysql_query("select * from video order by id DESC" ) or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['id'];
?>
但是,我的视频播放器是空白的,因为它无法播放。
修改:我使用此代码显示我的值
<ul>
<?php
$sql = "SELECT * FROM `mytable`";
foreach ($db->query($sql) as $row) {
$li = '<li> data-thumb-source="' .$row['data-thumb-source']. '"';
$li .= ' class="playlistItem" data-type="local"';
$li .= ' data-video-source="' .$row['data-video-source']. '"';
$li .= ' minimalDarkThumbnailTitle="' .$row['minimalDarkThumbnailTitle']. '"';
$li .= ' minimalDarkThumbnailDesc="' .$row['minimalDarkThumbnailDesc']. '"';
echo $li;
}
$db = null;
?>
</ul>
但这并没有什么不同。
答案 0 :(得分:0)
在定义属性之前,您已关闭了开始li
标记。
<ul>
<?php
$sql = "SELECT * FROM `mytable`";
foreach ($db->query($sql) as $row) {
$li = '<li data-thumb-source="' .$row['data-thumb-source']. '"';
$li .= ' class="playlistItem" data-type="local"';
$li .= ' data-video-source="' .$row['data-video-source']. '"';
$li .= ' minimalDarkThumbnailTitle="' .$row['minimalDarkThumbnailTitle']. '"';
$li .= ' minimalDarkThumbnailDesc="' .$row['minimalDarkThumbnailDesc']. '"';
echo $li . '>descriptions</li>';
}
$db = null;
?>
</ul>