Ray Favereau
Ray Favereau

Reputation: 11

How to pass a string from php/mysql database to existing xml video playlist

I've created an sql database that includes videos. I have created the php seach code and are able to search the database and return values with no problems.

I want to pass a URL string to an existing xml page so the xml page will open the url path and play the video.

The name of the string is $results[download_url] which returns the URL of the video on my php page. I also have assigned it to a new string $download_url2=$result['download_url']; and echo the results on my movie_player.php page which is returning the URL path on that page with no problem.

What I need is to pass that string to an existing XML page (medialist.xml) that shows the "path" of the video. Below is the code from the medialist.xml page

<?xml version="1.0" encoding="UTF-8" ?> 
<playlist>
<playitem caption="My Caption 1" path="video1.flv" image="My_Caption1.jpg" options="" clickurl="" clicktarget="_blank" endurl="" styleoftarget="browser" endtarget="" /> -->
<playitem caption="My Caption 2" path="video2.flv" image="My_Caption2.jpg" options="" clickurl="" clicktarget="_blank" endurl="" styleoftarget="browser" endtarget="" /> 
<playitem caption="My Caption 3" path=" (This is where I want the string to show the path. Like $download_url2) " image="My_Caption3.jpg" options="" clickurl="" clicktarget="_blank" endurl="" styleoftarget="browser" endtarget="" /> 
</playlist>

I've tried all sorts of suggestions from what I've found on the web. Is there a simple way to pass that string to an existing xml page?

Upvotes: 1

Views: 217

Answers (1)

Jeff Winkworth
Jeff Winkworth

Reputation: 4996

You XML file will need to be dynamically generated. Since you're using PHP, create a file called medialist.php. Alternately, you could use some mod_rewrites or other server settings to point medialist.xml to a dynamic script.

At the beginning of the file, include the following:

<?php
header("Content-Type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
?>
<!-- XML code -->

From there, you can process any PHP query string parameters and echo values to the screen as part of your XML response.

Upvotes: 2

Related Questions