Jump to content

Deleting a row with a link (MySQL)


rwachowiak

Recommended Posts

heres what i got so far:

 

when i click the delete link it wants to actually download the update.php

 

<?php include 'libs/dbopen.php';


//If cmd is not hit
if(!isset($cmd)) 
{	
	$query  = "SELECT * FROM news Order by DateAdded DESC";
	$result = mysql_query($query);
  
  
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
echo 	"<span class='titlebar3'><a href='update.php?cmd=delete&id={$row['id']}'>{$row['Title']} - Delete</a></span><br>" .
	"{$row['Content']} <br>" .
	"<span class='description'>Date Added: {$row['DateAdded']}</span> <br><br>";
	}		
}
?>




<?
if($cmd=="delete")
{
    $sql = "DELETE FROM news WHERE id={$row['id']}";
    $result = mysql_query($sql);
    echo "Row deleted!";
}
include 'libs/dbclose.php';
?>

Link to comment
https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/
Share on other sites

Just a shot here, since I assume you mean the update.php and not upload.php and assuming PHP is installed and works.

 

Try to change your <? tag to <?php

 

whoops yes, it is update.php

 

and yes php is installed and working fine, i have a few other scripts ive got going on this site

 

and i tried that <?php and no luck!

When you hover over the URL, how does it look in your status bar?

 

Also, where do you $_GET['cmd'] and $_GET['id'] ?

 

links look like:

 

http://srv2/update.php?cmd=delete&id=1

 

what do you mean where do i get those?! i suppose im missing something lol

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.