嗨,我从一个有效的表中得到了这个下拉列表。
$cat_id=$_GET['cat_id'];
require "configure.php";
$q=mysql_query("select * from arbejdsopgave where cat_id='$cat_id' and status2!='lukket'");
echo mysql_error();
$myarray=array();
$str="";
while($nt=mysql_fetch_array($q)){
$str=$str . "\"$nt[subcategory]\"".",";
}
$str=substr($str,0,(strLen($str)-1)); // Removing the last char , from the string
echo "new Array($str)";
但是,我想在“sub_id”列的下拉列表中显示的字符串中添加一列,以便下拉列表显示 sub_id - 子类别。例如:
673 - 新屋顶而不是仅显示新屋顶的当前。
我尝试如下组合一个字符串,但结果首先是子类别,然后是列表中的 subid,例如 subcat1 subcat2 subcat3 1 2 3
$cat_id=$_GET['cat_id'];
require "config.php";
$q=mysql_query("select * from arbejdsopgave where cat_id='$cat_id' and status2!='lukket'");
echo mysql_error();
$myarray=array();
$str="";
$subid="";
while($nt=mysql_fetch_array($q)){
$str=$str . "\"$nt[subcategory]\"".",";
$subid=$subid . "\"$nt[sub_id]\"".",";
$str2=$str." ".$subid;
}
$str2=substr($str2,0,(strLen($str2)-1)); // Removing the last char , from the string
echo "new Array($str2)";
希望你能在正确的轨道上帮助我