下拉式菜单 [英] Drop Down Menu

查看:49
本文介绍了下拉式菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我刚刚开始学习Mysql / PHP,我正在尝试设计一个带有下拉菜单的页面,这将允许用户选择他们想要的内容查看并提交查询。到目前为止这是我走了多远,我相信不远。


[PHP]<?PHP


/ /连接到数据库服务器

$ link = mysql_connect(" connection"," user"," pass");

//选择数据库

mysql_select_db(" db");


//执行MYSQL查询

$ result = mysql_query(''SELECT name FROM location_o2'')

或die( ''查询失败:''。mysql_error());


//以HTML格式打印结果

echo"< form action =''#''> \\\ n< select name = location> \\\\ n" ;;

while($ line = mysql_fetch_array($ result,MYSQL_NUM)){

$ house = $ line [0];

echo < option value = $ house> $ house\r\ n" ;;

}

echo"< / select> \\\\ n< input type = submit value = SELECT> \ r \ n< / form> ; \r\\\
英寸;


?> [/ PHP]


以上将创建一个包含2个条目的下拉菜单(伦敦,利物浦)。这个概念是用户选择一个城市,并通过提交他们的选择,他们可以在这种情况下查看该城市中所有可用的汽车。


任何想法和建议将受到极大关注。


keyvan

Hello every one,

I have just recently started learning Mysql/PHP and i am trying to design a page with drop down menus which will allow the user to select what they want to see and submit the query. So far this is how far i have gone, which i am sure is not far.

[PHP]<?PHP

// Connecting to the database server
$link = mysql_connect("connection", "user", "pass");
// Selecting database
mysql_select_db("db");

// Performing MYSQL query
$result = mysql_query(''SELECT name FROM location_o2'')
or die(''Query failed: '' . mysql_error());


// Printing results in HTML
echo "<form action=''#''>\r\n<select name=location>\r\n";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
$house = $line[0];
echo " <option value=$house>$house\r\n";
}
echo "</select>\r\n <input type=submit value=SELECT>\r\n</form>\r\n";

?>[/PHP]

The above will create a drop down menu with 2 entry (London, Liverpool). The concept is that the user selects a city and by submiting their choice they can in this case see all the available cars in that city.

any ideas and suggections will be greatly appriciated.

keyvan

推荐答案

link = mysql_connect(" connection"," user"," pass");

//选择数据库

mysql_select_db(" db");


//执行MYSQL查询
link = mysql_connect("connection", "user", "pass");
// Selecting database
mysql_select_db("db");

// Performing MYSQL query


result = mysql_query(''SELECT name FROM location_o2'')

或die(''查询失败:''。mysql_error());


//以HTML格式打印结果

echo"< form action =''#''> \\\ n< select name = location> \\\\ n" ;;

while(
result = mysql_query(''SELECT name FROM location_o2'')
or die(''Query failed: '' . mysql_error());


// Printing results in HTML
echo "<form action=''#''>\r\n<select name=location>\r\n";
while (


line = mysql_fetch_array(
line = mysql_fetch_array(


这篇关于下拉式菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆