我有一个使用下面下拉菜单中的变量的表。当用户在下拉列表中选择选项时,表格会根据与选择相关的变量提取信息。当页面第一次加载时,它会出错,说查询缺少下拉列表中的变量。如果我从下拉列表中进行选择,它会刷新页面并解决问题。我需要下拉菜单来最初提交数据或查询在初始页面加载时获取其变量所需的任何内容。
$selected = 'selected = "selected" ';
$Country =$ID_SOCIEDAD;
echo "<form name='country_list' method='POST' action='http://opben.com/colombia/familias-de-carteras' >";
echo "<select name='Country' tabindex='1' >";
while($row = mysql_fetch_array($result))
{
echo " <option ".($row['Fund_Manager_Company_Code'] == $Country? $selected : '')."value='". $row['Fund_Manager_Company_Code'] ."'>". $row['Fund_Manager_Company_Name'] ."</option>";
}
echo " </select>
<input type='submit' value='Filter' />";
echo " </form>
这是下拉菜单选项的 sql 查询:
$result = mysql_query("
SELECT
ID_SOCIEDADADM as Fund_Manager_Company_Code,
DES_SOCIEDAD_CORTO as Fund_Manager_Company_Name
FROM dr_lista_rentabilidad_diaria
GROUP BY ID_SOCIEDADADM
")
or die(mysql_error());
这是表的查询:
$result = mysql_query("
SELECT
ID_CARTERA as Fund_ID,
DES_CARTERA_CC as Fund_Name,
DES_CARTERACLASE as Class_Name,
DES_CARTERACLASE_ESP as Special_Class_Name,
FORMAT(POR_RENTCARTERA_C1,2) AS Yield_1month
FROM dr_lista_rentabilidad_diaria
WHERE COD_PAIS = $COD_PAIS
AND ID_SOCIEDADADM = $ID_SOCIEDAD
AND `ID_COLUMNA_C1`= $ID_COLUMNA
ORDER BY DES_CARTERA_CC ASC
")
or die(mysql_error());