0

Hi everybody, pls i need help here. i ve a video player and i want to populate video on it from mysql database, here is my code.

<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>

and i ve mysql database like this

 id | data-thumb-source | data-video-source | data-poster-source | minimalDarkThumbnailTitle | minimalDarkThumbnailDesc 

and php code to get the data from mysql

 <?php

                        $result= mysql_query("select * from video order by id  DESC" ) or die (mysql_error());
                        while ($row= mysql_fetch_array ($result) ){
                        $id=$row['id'];
                        ?>

but my video player is blank nothing to play. thanks in advance

4
Contributors
13
Replies
57
Views
2 Years
Discussion Span
Last Post by WebMedia_1
Featured Replies
  • 1
    diafol 3,720   2 Years Ago

    You could use sprintf() here using your markup as a template. I would do something like this: **vtemplate.php** <?php return <<<EOT <li data-thumb-source="assets/img/%s" data-video-source="assets/video/%s" data-poster-source="assets/img/%s" data-downloadable="yes"> <div data-video-short-description="%s"> <div> <p class="minimalDarkThumbnailTitle">%s</p> <p class="minimalDarkThumbnailDesc">%s</p> </div> </div> <div data-video-long-description="%s"> <div> <p class="minimalDarkVideoTitleDesc">%s</p> <p class="minimalDarkVideoMainDesc">%s</p> <p>For more information about this please follow <a … Read More

  • 1
    diafol 3,720   2 Years Ago

    Well that's down to you isn't it? Your table: id | data-thumb-source | data-video-source | data-poster-source | minimalDarkThumbnailTitle | minimalDarkThumbnailDesc Your connection and SQL: $template = include('vtemplate.php'); $mysqli = new mysqli("localhost", "user", "password", "database"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . … Read More

  • 1
    diafol 3,720   2 Years Ago

    Sorry. I forgot the $: $template = include('vtemplate.php'); $mysqli = new mysqli("localhost", "user", "password", "database"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $result= $mysqli->query("select * from video order by id DESC" ) or die (mysql_error()); $output = ''; while($row … Read More

  • @diafol thanks so much my video playlist is working courtesy of you, i owe u beer and pizza, u are a genuis Read More

0

How are you returning your data to the HTML from the PHP? Is that your question? If you have style='display:none;' for the CSS of the DIV then it won't display anything unless you change the CSS when something happens. JQuery works well for that but to get the data from the PHP into the HTML you just need to pay the PHP in the HTML where the data is supposed to be displayed and write it to the page using a number of methods. For instance if you have:

<div class='PHP CLASS NAME HERE'></div> you can write a class name with PHP as easily as <div class='<?php echo 'displayClass'; ?>'></div> and when the page renders the HTML will look like: <div class='displayClass'></div>

0

this is the code to display in my html list:

<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>

but still not working

Edited by WebMedia_1: edit

0

Looking at your code you will need to fix up your output to represent something like below, you are missing "p" tags. So just add them and you should be fine.

 <li data-source="list=PL5F394CB9AB8A3519" data-playlist-name="MY YOUTUBE PALYLIST" data-thumbnail-path="content/thumbnails/large2.jpg">
        <p class="minimalDarkCategoriesTitle"><span class="minimialDarkBold">Title: </span>My playlist 2</p>
        <p class="minimalDarkCategoriesType"><span class="minimialDarkBold">Type: </span>YOUTUBE</p>
        <p class="minimalDarkCategoriesDescription"><span class="minimialDarkBold">Description: </span>Created by loading a Youtube playlist, videos are loaded and played from Youtube.</p>
    </li>

Here is the link to the documentation:

http://www.animesonlines.com.br/player/documentation/

0

Thanks @andrevanzuydam but what i want to do is to get my html playlist as data from mysql database and i dont know how to do it, pls help me on it

Edited by WebMedia_1: edit

1

You could use sprintf() here using your markup as a template. I would do something like this:

vtemplate.php

<?php
return <<<EOT
<li data-thumb-source="assets/img/%s" data-video-source="assets/video/%s" data-poster-source="assets/img/%s" data-downloadable="yes">
    <div data-video-short-description="%s">
        <div>
            <p class="minimalDarkThumbnailTitle">%s</p>
            <p class="minimalDarkThumbnailDesc">%s</p>
        </div>
    </div>
    <div data-video-long-description="%s">
        <div>
            <p class="minimalDarkVideoTitleDesc">%s</p>
            <p class="minimalDarkVideoMainDesc">%s</p>
            <p>For more information about this please follow <a href="#" target="_blank">this link</a></p>
        </div>
    </div>
</li>
EOT;
?>

Just replace variable strings with %s. If you are placeholding integers or floats (e.g. time), then use %d or %f - but check the documentation on (s)printf. I counted 9 possible replacements.

display.php

Your script would be this:

<?php

$template = include('vtemplate.php');

//Retrieve data from DB into $result
//I am using mysqli here as an example
//You could use the PDO equivalent

$output = '';
while($row = mysqli_fetch_assoc($link, $result))
{
    //rename a,b,c... to match your fieldnames
    $output .= sprintf($template,$row['a'],$row['b'],$row['c'],$row['d'],$row['e'],$row['f'],$row['g'],$row['h'],$row['i']);
}
?>

Your markup is simply this:

<ul>
    <?=$output?>
</ul>

Edited by diafol

0

@diafol you did not specify where i will select my database from to get the video value. thanks

1

Well that's down to you isn't it?

Your table: id | data-thumb-source | data-video-source | data-poster-source | minimalDarkThumbnailTitle | minimalDarkThumbnailDesc

Your connection and SQL:

$template = include('vtemplate.php');
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

$result= mysqli->query("select * from video order by id  DESC" ) or die (mysql_error());
$output = '';
while($row = $result->fetch_assoc())
{
    $output .= sprintf($template, $row['data-thumb-source'], $row['data-video-source'], $row['data-poster-source'], "VIDEO SHORT DESCRIPTION", $row['minimalDarkThumbnailTitle'], $row['minimalDarkThumbnailDesc'], "VIDEO LONG DESCRIPTION", "Dark Video Title Desc" , "Dark Video Main Desc");
}

You don't seem to have feilds in your table for 4 of the things in your template - I've noted these with text instead of row fields.

0

thanks @diafol for help, but it shows me error: Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in line 568 which is this line

 $result= mysqli->query("select * from video order by id  DESC" ) or die (mysql_error());

Edited by WebMedia_1: edit

0

the above was resolved but another Fatal error: Call to a member function fetch_assoc() on resource in this line
while($row = $result->fetch_assoc())

Edited by WebMedia_1: edit

1

Sorry. I forgot the $:

$template = include('vtemplate.php');
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$result= $mysqli->query("select * from video order by id  DESC" ) or die (mysql_error());
$output = '';
while($row = $result->fetch_assoc())
{
    $output .= sprintf($template, $row['data-thumb-source'], $row['data-video-source'], $row['data-poster-source'], "VIDEO SHORT DESCRIPTION", $row['minimalDarkThumbnailTitle'], $row['minimalDarkThumbnailDesc'], "VIDEO LONG DESCRIPTION", "Dark Video Title Desc" , "Dark Video Main Desc");
}

Note change to: $result= $mysqli->query("select * from video order by id DESC" ) or die (mysql_error());

1

@diafol thanks so much my video playlist is working courtesy of you, i owe u beer and pizza, u are a genuis

0

You're welcome. Nice to fire up a few concepts again: template via sprintf and using return in a include file so you can assign it to a variable instead of reading the file. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.