Click here to Skip to main content
12,999,628 members (62,153 online)
Rate this:
Please Sign up or sign in to vote.
I have dynamically created a video list from my database. For that I have done my code in 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>';
            $countli = $countli+1;
 else {
     $post = $row['post'];
            $link = $row['link'];
            $HTML.='<video ><source src="' . $link . '" /source>';
            $HTML.='<a href="#"  önClick="javascript:vidSwap('. $link.');">Link</a></video>';
            $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:
<pre lang="HTML">
<div id="leftcolumn">
                            <video id="myvideo" controls='true' style="width:820px;height:360px"

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

But, when I am clicking in a video file from the list its working. Where is the problem I don't understand.
Posted 25-Apr-13 6:26am

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

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 25 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100