How do I edit mysql row data

0 favourites
  • 3 posts
From the Asset Store
DATA+ (Addon Pack)
$11.25 USD
50% off
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hi, I can add to my game data to mysql with the code below, but I need help on how to edit published data by using id number,

    I couldn't create the php code to edit the data by id number? I really need help...

    [quote:3hrcfudm]<?php

    $db = "tetuan_construct2";//Your database name

    $dbu = "tetuan_construct";//Your database username

    $dbp = "constructconstruct";//Your database users' password

    $host = "localhost";//MySQL server - usually localhost

    $dblink = mysqli_connect($host,$dbu,$dbp,$db);

    if(isset($_GET['name'])){

    $name = mysqli_real_escape_string($dblink,$_GET['name']);

    $sql = mysqli_query($dblink, "INSERT INTO `$db`.`scores` (`id`,`name`) VALUES ('','$name');");

    if($sql){

    echo 'Success';

    }else{

    echo 'Error';

    }

    }else{

    echo "Add ?name=NAME_HERE&score=1337 to the tags.";

    }

    mysqli_close($dblink);

    ?>

  • I use this edit code, but it doesnt work:

    [quote:aity22d8]<?php

    $db = "tetuan_construct2";//Your database name

    $dbu = "tetuan_construct";//Your database username

    $dbp = "constructconstruct";//Your database users' password

    $host = "localhost";//MySQL server - usually localhost

    $dblink = mysqli_connect($host,$dbu,$dbp,$db);

    if(isset($_GET['id'])){

    $name = mysqli_real_escape_string($dblink,$_GET['id']);

    $result = mysqli_query($mysqli, "UPDATE scores SET name='$name',user='$user',score='$score' WHERE id=$id");

    if($sql){

    echo 'Success';

    }else{

    echo 'Error';

    }

    }else{

    echo "Add ?name=NAME_HERE&score=1337 to the tags.";

    }

    mysqli_close($dblink);

    ?>

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok I got it this way...

    [quote:3nmqwjjo]<?php

    $servername = "localhost";

    $username = "tetuan_construct";

    $password = "constructconstruct";

    $dbname = "tetuan_construct2";

    // Create connection

    $conn = mysqli_connect($servername, $username, $password, $dbname);

    // Check connection

    if (!$conn) {

    die("Connection failed: " . mysqli_connect_error());

    }

    if(isset($_GET['name']) && isset($_GET['score']) && isset($_GET['user']) && isset($_GET['idno'])){

    $name = $_GET['name'];

    $score = $_GET['score'];

    $user = $_GET['user'];

    $idno = $_GET['idno'];

    }

    $sql = "UPDATE scores SET user='$user',score='$score',name='$name' WHERE id=$idno";

    if (mysqli_query($conn, $sql)) {

    echo "Record updated successfully";

    } else {

    echo "Error updating record: " . mysqli_error($conn);

    }

    mysqli_close($conn);

    ?>

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)