如何从MYSQL获取表名到组合框并将所选值分配给变量? [英] How to get table's name from MYSQL to combobox and assign selected value to variable?

查看:69
本文介绍了如何从MYSQL获取表名到组合框并将所选值分配给变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在PHP中遇到了使用combobox的问题。

我尝试将表的名称改为组合框,这是有效的。但我无法获得选定的值并分配给变量。请帮我。谢谢。

这是我的代码:

Hello,
I have a problem with combobox in PHP.
I try to get table's name to combobox, it's work. But I can't get selected value and assign to variable. Please help me. Thank you.
Here is my code:

$db= mysql_connect("localhost","root","");
	if(!$db)
	{
		echo "error";
		exit;
	}
$table = mysql_query("show tables from sctv_data2 LIKE '%nhap_%'");
echo "<select name = 'venue' >";
while (($row = mysql_fetch_row($table)) != null)
{
    echo "<option value = '{$row['0']}'";
    if ($selected_venue_id == $row['0'])
        echo "selected = 'selected'";
    echo ">{$row['0']}</option>";
}
echo "</select>";
if(isset($_POST['button']))
{
	$a =  $_POST['venue'];
	echo $a; // it's not print $a

推荐答案

db = mysql_connect( localhost root );
if(!
db= mysql_connect("localhost","root",""); if(!


db)
{
echo 错误;
退出;
}
db) { echo "error"; exit; }


table = mysql_query( 显示来自sctv_data2的表LIKE'%nhap _%');
echo < select name ='场地'>;
while ((
table = mysql_query("show tables from sctv_data2 LIKE '%nhap_%'"); echo "<select name = 'venue' >"; while ((


这篇关于如何从MYSQL获取表名到组合框并将所选值分配给变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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