- Impact
- 24
php/mysql: passing url variables to query & outputting to html
I'm conjuring up a video player and it works (rather crudely) but not as efficiently as I would like.
There are 2 main files involved: videolist.php and player.php
videolist.php outputs mysql into rows with variables $title, $video & $description. From there, I am passing $video & $title which will load the video into Windows Media Player.
videolist.php:
player.php:
... this gets the job done but I would like to only pass $id to player.php which would execute a query then echo $video, $title, into the existing html.
What must I do? Thanks in advance for your input!
I'm conjuring up a video player and it works (rather crudely) but not as efficiently as I would like.
There are 2 main files involved: videolist.php and player.php
videolist.php outputs mysql into rows with variables $title, $video & $description. From there, I am passing $video & $title which will load the video into Windows Media Player.
videolist.php:
Code:
<?php
include 'library/config.php';
$query = "SELECT * FROM $table ORDER BY id ASC";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo ("<a href=\"player.php?video={$row['video']}&title={$row['title']}\">{$row['title']}</a><br
/>{$row['description']}<br />");
}
include 'library/closedb.php';
?>
Code:
<?php
$video=$_GET['video'];
$title=$_GET['title'];
?>
<html>
<body>
<div class="title"><? echo $title; ?></div>
<div id="player"><object id="MediaPlayer" width="720" height="540" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">
<param name="autoStart" value="True">
<param name="filename" value="media/<? echo $video; ?>">
<param name="ShowControls" value="True">
<param name="ShowStatusBar" value="True">
<embed type="application/x-mplayer2" SRC="media/<? echo $video; ?>" name="MediaPlayer" width="640" height="480" autostart="1" showcontrols="1"></embed></object>
</div>
</body>
</html>
What must I do? Thanks in advance for your input!
Last edited:





