-2

So i have this database with registering. And in the backend i want to be able to change their status of payment.

I want a basic textarea where i can paste the ID of the user, and then an okay button to send the method, and then i click okay, i want it to update the users status with the particular id.

Can anyone help how to make connection to the database, where i only update their status if they have that id?

I now the html, i just need the php part.

I don't have any idea on how to do it, so i haven't tried anything yet.

  • 3
    Please try to use the search; http://stackoverflow.com/questions/23945476/php-sql-update-array – BBQ. Aug 13 '15 at 13:30
  • 2
    If you're wondering why you got dowvoted , then consider reading [this](http://stackoverflow.com/help/mcve). We expect your attempt for the problem you're trying to search, provided input, expected output and errors if any. Consider adding this stuff and we will glad to help. – Dipen Shah Aug 13 '15 at 13:31
  • 2
    possible duplicate of [Best way to write PHP SQL Update Statement](http://stackoverflow.com/questions/5433561/best-way-to-write-php-sql-update-statement) – BBQ. Aug 13 '15 at 13:32

1 Answers1

0

For database connection, use this:

database.php

<?php
try{
    $db = new PDO('mysql:host=localhost;dbname=your db name', "username" , "password");
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


}catch(PDOException $e){
    print "error in connection" . $e->getMessage();
}

update-Id.php

for udating/changing the value of user Id stored in database

<?php
    require_once 'database.php';
    $userId = $_POST['userId'];

$stmt = $db->prepare("UPDATE tablename SET userId  = ?");
        $stmt->execute(array($userId));
gbestard
  • 1,177
  • 13
  • 29
Itz Raghu
  • 457
  • 2
  • 6
  • 16