-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
  • 3
    Please try to use the search; stackoverflow.com/questions/23945476/php-sql-update-array Commented Aug 13, 2015 at 13:30
  • 2
    If you're wondering why you got dowvoted , then consider reading this. 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. Commented Aug 13, 2015 at 13:31
  • 2
    possible duplicate of Best way to write PHP SQL Update Statement Commented Aug 13, 2015 at 13:32

1 Answer 1

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));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.