Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:45:12+00:00 2026-06-12T21:45:12+00:00

I have a MySQL database table called ‘Videos’ with only three columns (fields?): ID,

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:45:13+00:00Added an answer on June 12, 2026 at 9:45 pm

    It looks like they are deprecating the mysql calls and recommend using the mysqli object oriented calls instead.

    https://www.php.net/manual/en/function.mysql-connect.php

    <?php
        $mysqli = new mysqli("host", "username", "password", "database name");
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
        }
        echo $mysqli->host_info . "\n";
        
        $res = $mysqli->query("SELECT EmbedURL FROM `Videos` ORDER BY RAND() LIMIT 1");
        $row = $res->fetch_assoc();
    ?>            
    
    <iframe width="560" height="315" src="<?php echo $row['EmbedURL']; ?>" frameborder="0" allowfullscreen></iframe>
    
    <p><?php echo $row['EmbedURL'];?></p>
    

    This worked for me on my local server running php 5.4. The first comment on the constructor recommends using a different set of commands if you are are using a php version below 5.2.9.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database table called character with columns like name, strength, intelligence,
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have a mysql database with a table structure like below : Table Name
I have a mysql database table called POST . One of the fields is
I have a MySQL Database. In it's table is a field called 'itm_name' I'm
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a table in my MySQL database called studentname . I made an
I have a table called profile in mysql database Table structure: user | hasimg
I have a MYSQL database table called 'wp_quotes' with a field that contains a
I have names stored in my mysql database i created a table called users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.