doqo89924 2015-10-26 04:20
浏览 39
已采纳

如何在php页面的选项列表中显示sql行

I have create 3 categories. in sql named as Buyer, Seller and Common. I want to display them in my page as select option with drop down.

basically i want if user post some thing. he should chose that category. and in future if any one click on these categories.

it should display all the content which linked to that category.

here is my php

include "connect.php"; 
$sql="SELECT Seller,Buyer, Common FROM category order by name"; 

echo "<select name= Buyer value='Buyer'>Buyer</option>";

foreach ($dbo->query($sql) as $row){

echo "<option value=$row[Buyer]>$row[Seller]</option>"; 

}

echo "</select>";

and my data base table

enter image description here

  • 写回答

2条回答 默认 最新

  • dougua3705 2015-10-26 04:31
    关注

    replace this line, also add quotes to your value and use {}

    echo "<option value='{$row['Buyer']}'>{$row['Seller']}</option>"; 
                        ^               ^
    

    Also when you are concatenating the arrays in echo, its good to use {}, else you will get syntax errors.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题