选择所有选项值php mysql [英] Select all option values php mysql

查看:63
本文介绍了选择所有选项值php mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从MySQL数据库中选择所有值。选项a,b和c可以正常工作,但是我不确定选择所有这三个语法。

I'm trying to select all values from my MySQL database. Options a, b, and c work fine but I'm not sure of the syntax to select all three.

<option value="1">a</option>
<option value="2">b</option>
<option value="3">c</option>
<option value="1,2,3">All</option>


推荐答案

我认为您想使用select来获取项或所有项,如果我能正确理解您的问题并查看全部选项的值。

I think you want to use the select to fetch a item or all items if I understand your question correctly and by seeing your 'all' option's value.

如果是,则将所有选择选项的值都更改为< option value = all>所有项< / option>

If so then change your select option's value for all to <option value="all">all items</option>.

然后将您的PHP文件(使用表单发布到此处)更改为:

Then change your PHP file (where you posting to with the form) to this:

// is the all option send?
if($_POST['your_select'] == 'all') {
    //query to get all the items (SELECT * FROM table)
} else {
    // query with the post value as the id (SELECT * FROM table WHERE id = $_POST['your_select'])
}

这篇关于选择所有选项值php mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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