i have one combo box in one html page another page i want to call the database.in the database select the customer name these names are diaplayed in combo box respectively.please the code for me.
1条回答 默认 最新
- duancan65665 2011-03-16 08:27关注
First off, Don't use
mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
<?php $db_name = "db"; $connection = mysql_connect('localhost','root','') or die(mysql_error()); $db = mysql_select_db($db_name,$connection) or die(mysql_error()); $sql = "SELECT customer_name,id from customers ORDER BY customer_name desc"; $result = mysql_query($sql,$db) or die(mysql_error()); if(mysql_num_rows($result)>=1){ $form = '<form method="POST" action=""> <p>Customer name:<select size="1" name="customer">'; while ($row = mysql_fetch_array($result)) { $form .='<option value="'.$row['id'].'">'.ucwords($row['customer_name']).'</option>'; } $form .=' </select></p><p><input type="submit" value="Submit"></p></form>'; } echo $form; ?>
解决 无用评论 打赏 举报
悬赏问题
- ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号