Jump to content

[SOLVED] DELETE??


JJohnsenDK

Recommended Posts

Hey

How do i delete one row from a table?

Im trying this:

[code]
<?php
include('../config.php');
$sql = "DELETE picture FROM player WHERE player_id = '".$_GET['player_id']."'";
$result = mysql_query($sql);
echo "Billede er slette. <a href='player_edit.php?player_id=".$_GET['player_id']."'>klik her for at vende tilbage.</a>";
?>
[/code]

but get this error:
[i]Unknown table 'picture' in MULTI DELETE[/i]
Link to comment
https://forums.phpfreaks.com/topic/33464-solved-delete/
Share on other sites

The delete syntax looks like this...

[color=blue]DELETE FROM table_name WHERE column_name = condition[/color]

So try this:

[code]<?php
include('../config.php');
$sql = "DELETE FROM player WHERE player_id = '".$_GET['player_id']."'";
$result = mysql_query($sql);
echo "Billede er slette. <a href='player_edit.php?player_id=".$_GET['player_id']."'>klik her for at vende tilbage.</a>";
?>[/code]

This will delete the whole row.  If you just want to change the value of one column, then use an update statement...

[code=php:0]$sql = "UPDATE player SET picture = null WHERE player_id = '".$_GET['player_id']."'";[/code]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/33464-solved-delete/#findComment-156630
Share on other sites

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.