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 8440381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:16:55+00:00 2026-06-10T08:16:55+00:00

In my MySQL database there is a column for VideoID and VideoCode I have

  • 0

In my MySQL database there is a column for VideoID and VideoCode

I have a PHP function in backend.php that aims to pick the next video in the list as follows:

$VideoID = 0;

function nextvideo(){
    global $VideoID;
    $VideoID = $VideoID + 1;
    $sql = mysql_query("SELECT * FROM Videos WHERE VideoID = '".$VideoID."'");
    $result = mysql_fetch_array($sql);
    return $result[2];
}

$VideoCode = nextvideo();

I then have the $VideoCode variable echo in my front end file inside a url that gives the embedded video.

That is all fine and it works, each time the nextvideo() function is called it picks the next $VideoCode correctly. However I want to implement a ‘next’ button that allows the user to effectively call the nextvideo() function and therefore load the next video. So I know i need to use AJAX and the .get() function but I have no idea how to use it and have tried reading up on it. So far I have this:

<script type="text/javascript">
  function next() {
      $.get("backend.php", *1*, *2*);
      return false;
  }
</script>

<a href="#" onclick="next();">Next</a>

I know that after backend.php in the $.get() function i need some more info, *1* being something to send to the backend file and *2* being what to do with the result once its sent back. This is where I am stuck.

Does *1* need to be nextvideo() because that’s the PHP function i wish to call, then *2* be something that will refresh the page so that the $VideoCode variable is updated and the next video is updated? Reading the documentation i know it needs to look something like:

$.get("test.php", function(data){
    alert("Data Loaded: " + data);
});

But what is function(data)?

  • 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-10T08:16:56+00:00Added an answer on June 10, 2026 at 8:16 am

    function(data) is a javascript function which is called when the request completes, passing in the variable data which is the page returned from the server. So in other words, when the request completes the code in that function will be executed and the variable data will contain whatever the server sent back from your request.

    What you want to do is something like this

    <script type="text/javascript">
      function next() {
         var currentVideoId = $('#videoId').val();
         $.get("backend.php", { videoId: currentVideoId }, function(data) {
            $('#video').html(data); 
            $('#videoId').val($('#videoId').val() + 1);
         });
         return false;
      }
    </script>
    
    <a href="#" onclick="next();">Next</a>
    

    Where you have a hidden input field with id videoId which has a value of the current video’s id and an element with id video which is the element to be updated with the new video.

    Your PHP script would look something like this:

    $VideoID = intval($_GET['videoId']) + 1;
    $sql = mysql_query("SELECT * FROM Videos WHERE VideoID = '".$VideoID."'");
    $result = mysql_fetch_array($sql);
    echo $result[2];
    

    This accepts the $_GET variable being passed in by the AJAX function and prints out the video code which is sent to the data variable in the javascript.

    Hopefully this helps, if you’re still unsure of anything please ask!

    • 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 called csftdb and in that database there exists 1
I have one problem... There is a table in my MySQL database that stores
I have a mySQL database table with a column that corresponds to an image
I have built a table from a MYSQL database using PHP. There are 4
I have a simple mySQL database table that I am loading into a PHP
I have a mysql database in which there is about hundreds of category for
In a MySQL (5.1) database table there is data that represents: how long a
Is there a way to query a MySQL database that gives me all blobs
Is there any application that will read a MySQL database table and generate a
I have several data s in MySQL database. In my table there is a

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.