-1

this is so that I will have to build a delete function, I try to google it but no luck was with me. then could not find a good function or whatever you call it.

this is so that I will have to delete a user

Hope you / i can help me further

It is the first time that I have to use the delete function in MySQLI to my website. :)

hope you can give me some information.

Jesper Petersen
  • 33
  • 1
  • 1
  • 5
  • 1
    [`DELETE FROM tablename WHERE somecol = 'someval'`](http://dev.mysql.com/doc/refman/5.0/en/delete.html) – DaveRandom Jun 20 '12 at 13:44
  • You can't find anything related using a modern search engine and the terms "delete+mysql"? I won't believe that… – feeela Jun 20 '12 at 13:53

2 Answers2

1

i am guessing you want to delete user from you mysql table, if yes then you can write a query using mysql DELETE keyword

"DELETE FROM `your-tbale(i.e users)` where `columnName` = 'somevalue'"

hope this is what you are looking for

Khurram
  • 711
  • 5
  • 10
  • "DELETE FROM `brugere` where `id` = '$_SESSION["user_id"]'" – Jesper Petersen Jun 20 '12 at 13:51
  • yeah you got it, and make sure you passed escaped data to your queries to avoid sql injections. – Khurram Jun 20 '12 at 13:52
  • yes :) How to do it like I do here with the updater if ($stmt = $mysqli->prepare('UPDATE `brugere` SET `password`=? WHERE `id`=?')) { $stmt->bind_param('si', $password, $id); $password = sha1($_POST['password']); $id = $_SESSION["user_id"]; $stmt->execute(); $stmt->close(); – Jesper Petersen Jun 20 '12 at 13:57
  • 1
    i think you might want to look into the follwing post [http://stackoverflow.com/questions/8145520/mysqli-update-query-issue] – Khurram Jun 20 '12 at 14:00
  • sorry but it make me confused to get anything as I have no need for all .. :) I just need it quick and enkeldt if you can put it like that. – Jesper Petersen Jun 20 '12 at 14:09
  • 1
    i am not getting u dear, ur question `title` says that u want to delete something, ur above comment says that you want to update something, what exactly u want ? and there is no mysql Delete or update function, its wot u have to use in this way( i guess i am not wrong ), so what it is it that you actually trying to do ? – Khurram Jun 20 '12 at 14:13
  • i still can edit my answer according to your need, so try to be specific dear – Khurram Jun 20 '12 at 14:14
  • Okay. hope it's okay with you :) – Jesper Petersen Jun 20 '12 at 14:19
0

Basically you only need to run the query:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

http://dev.mysql.com/doc/refman/5.0/en/delete.html

However it seems that you find "special problems" with that, probably this post will give you a hint:

Mysqli DELETE QUERY not working in PHP Script

Community
  • 1
  • 1
ruckuus
  • 18
  • 4