Forum Moderators: coopster

Message Too Old, No Replies

MySQL + PHP Audio Reference

How can I save my audio's location in the database and the code the webpage

         

haywars

2:33 am on May 27, 2010 (gmt 0)

10+ Year Member



Hi everyone I have been on countless forums and just cant seem to find the answer to this.

"How can I save my audio's location in the database and the code the webpage so when you click on the link it plays the audio file that is saved in the same row as the rest of the text?"

I found a forum on this same site with the exact same question I have but wasn't answered.

My code is:

<object width="300" height="42">
<param name="src" value="gtr.mp3">
<param name="autoplay" value="true">
<param name="controller" value="true">
<param name="bgcolor" value="#FF9900">
<embed src="gtr.mp3" autostart="true" loop="false" width="300" height="42" controller="true" bgcolor="#FF9900"></embed>
</object>

<table border="1" width="75%" cellpadding="2" cellspacing="2">
<tr>
<td align="center">Cue Code</td>
<td align="center">Cue Title</td>
<td align="center">Cue Description</td>
<td align="center">Time</td>
<td align="center"></td>
</tr>

<?php
mysql_connect("localhost", "*****", "*****") or die(mysql_error());
echo "Connected to MySQL<br /><hr />";
mysql_select_db("elixclot_music") or die(mysql_error());
echo "Connected to Database<br /><hr />";
$query = "SELECT * FROM tracks";
$result = mysql_query($query) or die(mysql_error());
while($line = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td align='center'>".$line[cue_code]."</td>";
echo "<td align='center'>".$line[cue_title]."</td>";
echo "<td align='center'>".$line[cue_description]."</td>";
echo "<td align='center'>".$line[time]."</td>";
echo "<td align='center'>"<a href='<?php echo $audiolocation; ?'>"<img src=\"http://example.com/img/speaker_dark.gif\" border=0>"</a>;
echo "</tr>";
}
?>


The site I am trying to mimic is <snip>

My page is located here but its not displaying. <snip>

As you can see I do not know how to link the Javascript with the audio. As well as have the audio play the selected tracks audio. What I did in my database was create a new column named "audiolocation" and made it "TEXT" and just wrote the location of the audio "/audio/track1.mp3"

Any help would be great!

[edited by: dreamcatcher at 6:04 am (utc) on May 27, 2010]
[edit reason] No urls please. See TOS. [/edit]

haywars

6:47 am on May 27, 2010 (gmt 0)

10+ Year Member



I actually figured out how to get this to work..