Skip to content
WJunction - Webmaster Forum

Mysql fetch specific data from row (id)

Status
Not open for further replies.
Ok so im not very good with all this mysql stuff but im having a go.

I have built a script that inserts into my DB the following:

Video Link (playable mp4,avi etc etc)
Video Title
Video download link

I now have my output done BUT im using the echo command to pull the media link from my DB into the media player

Example:


Code:
<OBJECT ID="MediaPlayer" WIDTH="192" HEIGHT="190" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject">
<PARAM NAME="FileName" VALUE="[COLOR="Red"]<?php echo("$vid_source"); ?>[/COLOR]">
<PARAM name="autostart" VALUE="false">
<PARAM name="ShowControls" VALUE="true">
<param name="ShowStatusBar" value="false">
<PARAM name="ShowDisplay" VALUE="false">
<EMBED TYPE="application/x-mplayer2" SRC="[COLOR="Red"]<?php echo("$vid_source"); ?>[/COLOR]" NAME="MediaPlayer"
WIDTH="192" HEIGHT="190" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"> </EMBED>
</OBJECT>


Now this works fine and plays the video BUT all the movie players play the same video so i need to use something like

Code:
<?php echo("$vid_source [COLOR="Red"]from[/COLOR] $id1"); ?>

Now of coarse this dosn't work and i didnt expect it to......so what do i put in there so it pulls the links from the diferent rows/id's from my DB.


Thanks
RR
 

9 comments

first of all you have to get the id of the video using $_GET from the user.
You can do something like this:

$id = $_GET['videoid'];
$sql = "SELECT * FROM table WHERE id={$id}";
$query = mysql_query($sql);
while($result = mysql_fetch_array($query)){
echo $result['id'] . $result['videolink'] . $result['videotitle']
}
 
Thanks for the quick response.

Take a look here ( ignore the cosmetic side at the moment please):

http://userporn.co.uk/new_site/out2.php

You will see from the text output there are 2 diferent MP4 links

But the media players only play the last one....

Here is my DB :

db.png


So i need to make this :
Code:
<?php echo("$vid_source"); ?>

echo the diferent links from the diferent ID's

Cheers
RR
 
Try this:
PHP:
<?PHP
$user_name = "DbUserName";
 $password = "DbPassword";
 $database = "DbName";
 $server = "localhost";

$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

$SQL = "SELECT vid_source FROM DbTableName";
$result = mysql_query($SQL);

while ($db_field = mysql_fetch_assoc($result)) {
echo $db_field['vid_source']."<br>";
}

 mysql_close($db_handle);

}
else {
echo "Database NOT Found ";
mysql_close($db_handle);
}

?>
 
Status
Not open for further replies.

About the author

R
Active Member · Joined
600
Messages
127
Reactions
43
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom