G
G
goldwizard132016-05-30 15:51:29
MySQL
goldwizard13, 2016-05-30 15:51:29

How to make a select form from the rows received from the database?

There is such code
$sql = $db->query("SELECT `str_code` FROM $db_str WHERE str_area='forma'");
while($item = $sql->fetch()){
$res = $item['str_code'];
}
you need to place the received lines from the database for input into the form as a select
< form method="post"> //the form itself
< select name="polling"> //drop-down menu that is clogged with an array
//filling the drop-down list
< /select>
< input type="submit" value="Ok" />

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-05-30
@goldwizard13

< select name="polling"> //выпадающее меню, которое забивается массивом
<?php while($item = $sql->fetch()):?>
<option><?=$item['str_code'];?></option>
<?php endwhile;?>
< /select>

A
Alex, 2016-05-30
@streetflush

php
echo in a loop.
and res array should be

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question