JJohnsenDK Posted January 9, 2007 Share Posted January 9, 2007 HeyHow do i delete one row from a table?Im trying this:[code]<?phpinclude('../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 More sharing options...
HuggieBear Posted January 9, 2007 Share Posted January 9, 2007 The delete syntax looks like this...[color=blue]DELETE FROM table_name WHERE column_name = condition[/color]So try this:[code]<?phpinclude('../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] RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/33464-solved-delete/#findComment-156630 Share on other sites More sharing options...
JJohnsenDK Posted January 9, 2007 Author Share Posted January 9, 2007 Allright, thanks for helping out. ;D Link to comment https://forums.phpfreaks.com/topic/33464-solved-delete/#findComment-156633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.