Search code examples
javascriptphpjquerysoundcloudoembed

"Unlink" echoed result from database


I'm using a plugin called Jquery-Oembed-All to embed audio from soundcloud. I have the track name, year and URL stored in a database and after a query the audio is embedded on my website. My problem is that the displayed text(track name & year) now also is links to the original url. I do not want this and I think it's pretty strange, I only want normal non linked text. Is it because of the script or is the problem on my side, like wrong coding? The jQuery looks like this and the link to the script is here https://github.com/nfl/jquery-oembed-all

  <script>
     $(function () {
        $("a.embed").oembed()
     });
  </script>

My query and echo.

$stmt = $DB_con->prepare("SELECT * FROM tbl_music ORDER BY trackid DESC");
$stmt->execute();
foreach ($stmt as $row) {
    $id = $row['trackid'];
    $nameembedded = $row['trackname'];
    $yearemebedded = $row['year'];
    $urlembedded = $row['url'];

    echo "<a href=\"$urlembedded\" class=\"embed\"></a>";
    echo "<div class=\"divinfo\"> Title: $nameembedded <br/>Year: $yearemebedded </div>";
}

Solution

  • anchor tags do not support self-closing syntax so it's removing the self-closing / piece and wrapping it's siblings inside the <a> tag. you should be able to just change this:

    echo "<a href=\"$urlembedded\" class=\"embed\"/>";
    

    to this:

    echo "<a href=\"$urlembedded\" class=\"embed\">View on SoundCloud</a>";