从 PHP 中的 mySQL 表填充下拉框 [英] Populate a Drop down box from a mySQL table in PHP

查看:25
本文介绍了从 PHP 中的 mySQL 表填充下拉框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 PHP 中根据 mySQL 查询的结果填充下拉框.我在网上查找了一些示例,并在我的网页上尝试了它们,但出于某种原因,它们根本没有填充我的下拉框.我试图调试代码,但在我查看的网站上并没有真正解释它,我无法弄清楚每一行代码是什么.任何帮助都会很棒:)

I am trying to populate a Drop down box from results of a mySQL Query, in Php. I've looked up examples online and I've tried them on my webpage, but for some reason they just don't populate my drop down box at all. I've tried to debug the code, but on the websites I looked at it wasn't really explained, and I couldn't figure out what each line of code. Any help would be great :)

这是我的查询:Select PcID from PC;

推荐答案

您需要确保如果您使用的是 WAMP 等测试环境,请将您的用户名设置为 root.下面是一个示例,它连接到 MySQL 数据库,发出您的查询,并为表中每一行的

发送“验证码”获取 | 15天全站免登陆