I'm trying to have a DELETE
link printed alongside each $row
. Also, on another page, have a "DOWNLOAD" link - they should work the same way. The problem is this: I am getting both DELETE and DOWNLOAD to print out alongside each record, but using the code I have, nothing happens or my script bails out on an error. For some reason I have the most complex features of my site up and running but this still eludes me. Here's some code:
while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC))
{
echo '<tr><td align="left">' .
$row['title'] . '</td><td align="left">'
. $row['genre'] . '</td><td align="left">'
. $row['length'] . '</td><td align="left">'
. $row['created'] . '</td><td align="left">'
. $row['views'] . '</td><td align="left">'
. "<a href='wprofile.php?id={$row['upload_id']}'>Delete</a></td> . '</td></tr>';
}
and on the same php page I have this logic which is failing me. the example is for delete but the same fail follows for my DOWNLOAD link problem.
if(isset($_GET['upload_id']))
{
$id = intval($_GET['upload_id']);
require_once (dbconnectionpath);
$delquery = "DELETE FROM 'upload' WHERE 'upload_id' = {$id}";
$done = @mysqli_query ($dbc, $delquery); //run the query
if($done) {
if (mysqli_num_rows($done)==1) {
echo 'Record deleted';
}
else{
echo 'Delete failed';
}
@mysqli_free_result($result);
}
else{
echo "Error! Query failed: <pre>{$dbc->error}</pre>";
}
mysqli_close(dbconnection);
the error I am getting is "Error, query failed"