calist Posted November 3, 2008 Share Posted November 3, 2008 I am very very new to PHP, I am building a website in which there are like 30 youtube videos for a training series. I would like to put the youtube links all in a MySQL database and then have them returned as embedded videos in a window in the file but I can't seem to find any way of doing this. Is it even possible. Here is what I was trying... Main Source File: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <link rel="stylesheet" type="text/css" href="mystyle.css" /> <title>The Recipe Center</title> <body> <table width="100%" border="0"> <tr> <td id="header" height="90" colspan="3"> <?php include("header.inc.php"); ?> </td> </tr> <tr> <td id="nav" width="15%" valign="top"> <?php include("nav.inc.php"); ?> </td> <td id="main" width="55%" valign="top"> <?php if (!isset($_REQUEST['content'])) include("ranger.inc.php"); else { $content = $_REQUEST['content']; $nextpage = $content . ".inc.php"; include($nextpage); } ?> </td> <td id="news" width="30%" valign="top"> <?php include("news.inc.php"); ?> </td> </tr> <tr> <td id="footer" colspan="3"> <div align="center"> <?php include("footer.inc.php"); ?> </div> </td> </tr> </table> </body> </html> Ranger.inc.php source file: <h2 align="center">Videos</h2><br> <?php $con = mysql_connect("localhost", "name", "pass") or die('Sorry, could not connect to database server'); mysql_select_db("website", $con) or die('Sorry, could not connect to database'); $query = "SELECT weekid, link from ranger order by weekid"; $result = mysql_query($query) or die('Sorry, could not get videos at this time '); if (mysql_num_rows($result) == 0) { echo "<h3>Sorry, there are no videos posted at this time, please try back later.</h3>"; } else { while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $weekid = $row['weekid']; $link = $row['link']; echo "<a href=\"ranger.php?content=showranger&id=$weekid\">$weekid</a><br>\n"; } } ?> ShowRanger.inc.php file <?php $con = mysql_connect("localhost", "name", "pass") or die('Sorry, could not connect to server'); mysql_select_db("website", $con) or die('Sorry, could not connect to database'); $weekid = $_GET['id']; $query = "SELECT link, weekid from ranger where weekid = $weekid"; $result = mysql_query($query) or die('Sorry, could not find video requested'); $row = mysql_fetch_array($result, MYSQL_ASSOC) or die('No records retrieved'); $link = $row['link']; $description = $row['description']; ?> <object width="425" height="349"> <param name="movie" value="http://www.youtube.com/v/W0G3wzVyR00&hl=en&fs=1&rel=0&color1=0x5d1719&color2=0xcd311b&border=1"> <param name="allowscriptaccess" value="always"> <?php echo "<a href=$link>h</a><br>\n";?> </object> The problem is that this makes it so someone has to click twice for the same file and then it still opens in a new window instead of embedding? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted November 3, 2008 Share Posted November 3, 2008 Umm, what? Also, please use tags when posting on the forum. And honestly, using the tab key when coding helps a LOT. Quote Link to comment Share on other sites More sharing options...
calist Posted November 3, 2008 Author Share Posted November 3, 2008 Sorry, I'm not sure what you mean? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted November 3, 2008 Share Posted November 3, 2008 Sorry, I'm not sure what you mean? You don't indent your code, which makes it really hard to keep track of. You should really practice formatting your code nicely. Anyway, what's actually wrong with the script? I don't see any major issues with the quick glance over I gave it. Quote Link to comment Share on other sites More sharing options...
calist Posted November 3, 2008 Author Share Posted November 3, 2008 I can't get it to embed the video in the file. It always opens a new window. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted November 3, 2008 Share Posted November 3, 2008 Care to provide a link? Quote Link to comment Share on other sites More sharing options...
calist Posted November 3, 2008 Author Share Posted November 3, 2008 I didn't actually upload it to a server but if you give me a minute or two I can do that and then post a link. I just have it on my computers server. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted November 3, 2008 Share Posted November 3, 2008 Please do, that way I can see what you're talking about. >_< Quote Link to comment Share on other sites More sharing options...
calist Posted November 4, 2008 Author Share Posted November 4, 2008 Obviously this is a rough draft, click on the 1. Link: http://www.laumantraining.com/lauman/ranger.php What I want is to be able to have the video open in that space that the 1 is floating in. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted November 4, 2008 Share Posted November 4, 2008 Well, on the second page, you're outputting a link in the object tag instead of actually embedding it. Look at the code that Youtube provides for embedding a video: object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/oobDQ0vdm8M&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/oobDQ0vdm8M&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> Go to your video and just copy and paste the Embed code. Quote Link to comment Share on other sites More sharing options...
calist Posted November 4, 2008 Author Share Posted November 4, 2008 What I was trying to get was that I have some thirty of these videos that all have to be on the site. I was hoping that I could put all of the links into a database. Then I wouldn't have to make 30 different html pages for each video. Quote Link to comment Share on other sites More sharing options...
calist Posted November 4, 2008 Author Share Posted November 4, 2008 I figured it out...If I put the entire object code in the database it works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.