开发者

SQL query won't populate my drop-down box

开发者 https://www.devze.com 2023-01-24 01:17 出处:网络
I have a problem with this query and drop down box: $ziua = \"SELECT DISTINCT DA开发者_运维问答YOFMONTH(ziua) FROM rapoarte\";

I have a problem with this query and drop down box:

$ziua = "SELECT DISTINCT DA开发者_运维问答YOFMONTH(ziua) FROM rapoarte"; 

$ziuaResult = mysql_query($ziua);

Populating the drop down box :

echo"<td>Selectati Ziua:</td>    
<td><select name='ziua'>     
<option value='---'>---</option>";

while($ziuaRow = mysql_fetch_array($ziuaResult)) 
{    
    $ziua1 = $ziuaRow['ziua'];     
    echo "<option value='$ziua1'>$ziua1</option>";
}

For an reason unknown to me, the drop down box is populated, but no values are shown. (there are 2-3 empty options)


That happens because there is no such column ziua in your query. Use alias in the query SELECT DISTINCT DAYOFMONTH(ziua) as dm FROM rapoarte and then $ziua1 = $ziuaRow['dm']; or access result by integer index $ziua1 = $ziuaRow[0];


The problem is that the field name is not correct. I have tried that as well. It will give you the reult.

0

精彩评论

暂无评论...
验证码 换一张
取 消