I think I'm confusing myself. What I want to do is to show the user all the records in a mySQL table and give them the option to delete the record by clicking on a field.
So far, I've got
Code: Select all
<?php
$dbconn = mysql_connect("localhost", "test", "test");
$result = mysql_select_db("jonat8", $dbconn);
if ( $result == false )
{
echo mysql_error();
} else {
$sql = "SELECT * from dalmedia";
$result = mysql_query( $sql );
if ( $result != false )
{
while ( $data = mysql_fetch_assoc( $result ) )
{
echo 'Track Details: '.
$dataї'artist'].' (<a href="javascript:deleteMedia('.
$dataї'filename'].')"><b>'.
$dataї'trackname'].'</a></b>)<br>';
}
} else {
echo mysql_error();
}
}
?>My idea was a javascript that nests a PHP statement, if you see what I mean, to delete the entry from the database (criteria being the filename), or is there a more efficient way to delete the record? I'm confusing myself with it... The filename is passed to the script, i.e.
Code: Select all
<SCRIPT LANGUAGE=JavaScript>
function deleteMedia(filename)Any suggestions greatly appreciated,
Thanks
Jonathan