0

Hello guys i'm sorry about the post but i require a little help

I am currently working on a page where information is passed from a database, i use tables on the page, and use sql query to grab all the results.

like this

getusers = $dbh->prepare("SELECT * FROM users WHERE status='0' ORDER BY id DESC");
                                $getusers->execute();
                                while($user = $getusers->fetch())
                                {
                                    echo'<tr>
                                    <td style="width: 20%;">'.$user["username"].'</td>
                                    <td style="width: 10%;">'.$user["age"].'</td>
                                    <td>'.$user["ip"].'</td>
                                    <td><button type="submit" name="Sub1">'.$user['username'].'</button></tr>';
                                    
                                }

all information i need is retuned and the buttons name will change to the username from the database.

for example username test button name would be test. if the username is jay the button is jay

heres what i want, when the button is pressed, i want to be able to get the username of the button from the database, so for example if i have a user in the db called jay, and i press the button that will show as jay, i want to only edit jays records

im sorry if i made this confusing

image

OhNo
  • 13
  • 2
  • You would need to give your button a value or use a hidden input. Is this all one big form with many buttons? I'd recommend creating a form tag for each record individually. – El_Vanja Mar 09 '21 at 16:32
  • It's like a user manager all users start with 0 as status, an admin would then see this as seen in the image, when the button is pressed it would rub the query to change the status for that user to 1. – OhNo Mar 09 '21 at 16:39
  • All the more reason to have individual forms for each user. See [forms inside a table](https://stackoverflow.com/questions/5967564/form-inside-a-table). – El_Vanja Mar 09 '21 at 16:42

0 Answers0