Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.