Query wird 2x eingetragen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Query wird 2x eingetragen

    Kann mir bitte jemand sagen, warum er die Anfrage 2x an die Datenbank sendet, wenn ich auf den "Send Friendship Request"-Link klicke?
    Code:
    if($getid != $userid)
    {
            $query =   mysqli_query($con, "SELECT id FROM friends WHERE (user1_id = '$userid' AND user2_id = '$getid') OR (user1_id = '$getid' AND user2_id = '$userid')");
            $numrows  =   mysqli_num_rows($query);
            if($numrows == 1)
            {
                echo "<a href=''>Already Friends</a> | <a href=''>Delete Friendship</a>";
            }
            else
            {
                $from_query   =   mysqli_query($con, "SELECT id FROM friends_req WHERE from_id = '$getid' AND to_id = '$userid'");
                $to_query     =   mysqli_query($con, "SELECT id FROM friends_req WHERE from_id = '$userid' AND to_id = '$getid'");
                $from         =   mysqli_num_rows($from_query);
                $to           =   mysqli_num_rows($to_query);
    
            if($from > 1)
            {
                echo "<a href=''>Ignore</a> | <a href=''>Accept Friendship</a>";
            }
            else if($to > 1)
            {
                echo "<a href='friends_request.php?action=cancel&id=$getid'>Cancel Request</a>";
            }
            else
            {
                echo "<a href='friends_request.php?action=send&id=$getid'>Send Friendship Request</a>";
            }
        }
    }
    Code:
    <?php date_default_timezone_set("Europe/Berlin") ?>
    <?php require_once("style/top.php"); ?>
    <?php
    
        $action =   $_GET['action'];
    
        $getid  =   $_GET['id'];
    
        if($action  ==  'send')
        {
            mysqli_query($con, "INSERT INTO friends_req (id, from_id, to_id) VALUES ('', $userid, '$getid')");
        }
    
        if($action  ==  'cancel')
        {
            mysqli_query($con, "DELETE FROM friends_req WHERE from_id = '$userid' AND to_id = '$getid'");
        }
    
    ?>

  • #2
    Weil.....
    Weil das Statement doppelt ausgeführt wird.

    Aber wie, wo und warum, KA.
    Wir werden alle sterben

    Kommentar

    Lädt...
    X