e107help.org Q&A
0 like 0 dislike
I have a table that consist of gameid, userid and username. What I want is the user to be able to delete a game from the list without deleteing other users games with the same id. For example

table usergames.............. user Blabla with USERID 1 deletes game with gameid 1 from the list without affecting other entries

gameid, userid, username

1           1         Blabla

1           2        Qwerty

2           1        Omg

3           4        Wadaduck

if (isset($_POST['delete_game'])){
    $delete = array(
    'gameid' => $gameid,
    'userid' => USERID,
    'username' => USERNAME
    $sql->insert('usergames', $delete);
    $text = e107::getMessage();
    $text->addSuccess('Game removed from the list.');
    echo $text->render();

Doesn't work and other means just delete the whole table.
e107 version 2.1.9
in Other by (9 points) 1 3

Why $sql->insert('usergames', $delete);?

insert() insert data to database.  

use delete()   

I am sure that there are examples in code and in official doc.

1 Answer

0 like 0 dislike

Please refer to the develop reference manual here: https://e107.org/developer-manual#database

$sql->delete("user", "user_id=2");

The second parameter is the WHERE argument. 

by (2.4k points) 6 8 8

Can you please post a link to your complete code? For example by sharing the link to your Github repository or by using Gist 

Okay, I just figured it out. I'm still learning php, still green. Thanks anyway.
Glad to hear you got it sorted out!
Welcome to e107 Q&A, where you can ask questions and receive answers from other members of the e107 community.
806 questions
1,209 answers
581 users