How to create a form where all site users will be displayed from the database so that you can select a user to edit his fields in the database? I tried it like this, it does not work.

<form action="index/func" method="post"> <?php $row = $this->db->prepare('SELECT id, login, password FROM users'); $row->execute(); $row->setFetchMode(PDO::FETCH_ASSOC); do { printf("<input type='radio' name='user' value='%s'>%s %s<br/><br/>", $row['id'], $row['login'], $row['password']); } while( $row->setFetchMode(PDO::FETCH_ASSOC)) ?> <input type="submit" value="Выбрать элемент"> </form> 
  • take and create, write code. - Jean-Claude

1 answer 1

It seems to be bad to display in radio, here is the conclusion to the list. If you really want to just replace the radio.

 $smth = $db->query('SELECT id, login, password FROM users'); while($row = $smth ->fetch()){ echo "<option value = ".$row['id'].'">'.$row['login'].'</option>'; }