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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:59:30+00:00 2026-05-31T01:59:30+00:00

I am searching for possibility to include a javascript function into a php code.

  • 0

I am searching for possibility to include a javascript function into a php code.

The code should get the results from the search php file and then print them out in form of a Javascript Playlist.

This is the javascript code:

<script type="text/javascript"> 
$(document).ready(function(){

var description = ''; 
var myPlaylist = [ {

    mp3:'./../sounds/mysql-upload',
    title:'mysql-title',
    artist:'mysql-artist',
    subcategory:'mysql-subcategory',
    date:'mysql-date',
    rating:'mysql-rating',
    },

    /* var myPlaylist has to repeat */

]; 

$('#main').ttwMusicPlayer(myPlaylist, { 
autoPlay:false, 
description:description, }
);

}); 
</script>

And here is the php code:

 <?php
    if (!empty($_POST['search'])) {

    /* Connect to database */
    $hostname = '';
    $database = '';
    $username = '';
    $password = '';
    if (!($mysql_link = mysql_connect($hostname, $username, $password))) {
    die('Could not connect');
    }

    /* Select databse */
    if (!($db_selected = mysql_select_db($database, $mysql_link))) {
        die('Could not find database');
    }

    /* Send mysql command */
    $sql_cmd = "SELECT * FROM sounds WHERE `keywords` LIKE '"
    . $_POST['search']."%'";
    if (!($res = mysql_query($sql_cmd))) {
        die('Invalid MySQL query');
    }

    /* Show results */
    while ($dsatz = mysql_fetch_assoc($res)) {

    $upload = $dsatz["upload"];
    $title = $dsatz["title"];
    $artist = $dsatz["artist"];
    $subcategory = $dsatz["subcategory"];
    $date = $dsatz["date"];
    $rating = $dsatz["rating"];

    /* Here should be the Javascript code */

    }

    /* Close database connection */
    mysql_close($mysql_link);
    }
?>

Please note that I don’t want to include the full Javascript function in the results part of the php code but the playlist variable which should repeat.

  • 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-05-31T01:59:31+00:00Added an answer on May 31, 2026 at 1:59 am

    In PHP, you can make an array, and fill it with arrays of those attributes.
    Something like:

    $results = array();
    while ($dsatz = mysql_fetch_assoc($res)) {
        $results[]=$dsatz; }
    $printout = json_encode($results);
    

    Now to put it into the JavaScript, you’d do this:

    var myPlaylist = <?php echo $printout; ?>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been searching about the possibility of propagate a JTA transaction from Java code
I'm searching for a possibility to get a list of installed printers. I'm using
Searching from google.com, like www.abc.com Search Result Rank the pages like Title..... Description... www.abc.com
I'm searching a possibility to get an array of elements in E4X for an
i am searching for a possibility to transform this code zero(0). positive(X) :- \+
Im searching for a very high performant possibility to insert data into a MS
At the moment I am searching for a possibility to include CRSF tokens in
I am searching for a possibility to replace the lowre input text field with
I'm currently searching for a possibility to order a mysql result by weights that
Searching for some sample code for converting a point in WGS84 coordinate system to

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.