I have a MySQL database table called 'Videos' with only three columns (fields?): ID, EmbedURL, and Name.
I'd like to use PHP (or something, anything) in the actual index.html to grab a random YouTube video from the DB and put the EmbedURL into an iFrame so that when the user clicks a button (or refreshes the page) another random video from the database loads.
I know I could do this with an iframe embed, like so:
<iframe width="560" height="315" src="http://www.youtube.com/embed/T0Jqdjbed40?playlist=SyoA4LXQco4,6l6PPvUhR4c" frameborder="0" allowfullscreen></iframe>
But I really want this simple, 1-page website to have a big, fun, attractive button to click, and the iframe embed player just has this boring "next" button.
Below is my code so far. As a starter step, I was just trying to see if I could get my page to display the EmbedURL that's saved in the database, but it's not echoing anything on the page, and I know it's not addressing the iframe issue.
I did a pretty thorough search (60min) and can't quite put the pieces together. The query is working in phpMyAdmin.
Any pointers appreciated.
[EDIT: My webhost is running PHP v. 5.2.17].
<?php
mysql_connect("localhost", "admin", "xxxxxxx") or die(mysql_error());
mysql_select_db ("my_db_name") or die(mysql_error());
$select = mysql_query("SELECT EmbedURL FROM `Videos` ORDER BY RAND() LIMIT 1");
while($row = mysql_fetch_assoc($select)) {
?>
<p><?php echo $row ['EmbedURL'] ?></p>