-
- 83 Posts
Hi!
I hawe this table:
table_structure.png
list of data:
table_list_data.png
This sample query:
SELECT name FROM category ORDER BY name DESC LIMIT 16
And I nedd in my web page form with
DropDown List (select one row) and button "Submit"
like TV:
TV_input_options.png
How create this DropDown List from DB (DB name: modx_revo_test, table: category, column: name) ?
Thanks!
:-)
[ed. note: puschpull last edited this post 12 years, 2 months ago.]
-
- 83 Posts
Now I testing this snippet
(code):
<?php
echo '<form action="[[~[[*id]]]]" method="post" class="form">
<select name="sel_cat" size="1">';
$database="database_name";
mysql_connect ("host.server", "user_name", "password");
mysql_query('SET NAMES utf8');
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT name FROM category ORDER BY id ASC LIMIT 8";
$result = mysql_query ($query);
while($nt=mysql_fetch_array($result)){
echo "\t<option value=\"".$nt['name']."\">".$nt['name']."</option>\n"; }
echo '</select>
<input type="submit" value="odeslat">
</form><br><hr>';
$a = ($_POST['sel_cat']);
echo 'vysledek: '.$a;
?>
and this work fine