Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have dynamically created a video list from my database. For that I have done my code in php:
PHP
$query = "select post,link from pagination order by id desc
limit $pageLimit," . PAGE_PER_NO;
$res = mysql_query($query);
$count = mysql_num_rows($res);
$HTML = '';
$countli = 1;
if ($count > 0) {
while ($row = mysql_fetch_array($res)) {
        if ($countli == 1) {
            $post = $row['post'];
            $link = $row['link'];
            $HTML.='<li class="active"><div>';
            $HTML.='<video ><source src="' . $link . '" /source>' . '<p>' . $post . '/<p>';
            $HTML.='<a href="#"  önClick="javascript:vidSwap('. $link.'); return false;">Link</a></video>';
            $HTML.='</div><br/>';
            $HTML.='</li>';
            $countli = $countli+1;
        }
 else {
     $post = $row['post'];
            $link = $row['link'];
            $HTML.='<li><div>';
            $HTML.='<video ><source src="' . $link . '" /source>';
            $HTML.='<a href="#"  önClick="javascript:vidSwap('. $link.');">Link</a></video>';
            $HTML.='</div><br/>';
            $HTML.='</li>';
            $countli = $countli+1;
 }
    }
} else {
    $HTML = 'No Data Found';
}
echo '<ul id="playlist">';
echo $HTML;
echo '</ul>';

As, while loading my page it automatically generate a video list. And in my html page there is a video player. Code:
HTML
<pre lang="HTML">
<div id="leftcolumn">
                            <video id="myvideo" controls='true' style="width:820px;height:360px"
                                preload="auto">
                            </video>
                        </div>


And my javascript code is:
JavaScript
<script type="text/javascrpt">
            function vidSwap(vidURL) {
            var myVideo = document.getElementById()('#myvideo')[0];
            myVideo.src = vidURL;
            myVideo.load();
            myVideo.play();
            }
        </script>


But, when I am clicking in a video file from the list its working. Where is the problem I don't understand.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900