开发者

Problem with PHP printing in drop down box

I have a mysql query开发者_StackOverflow中文版:

$ziua = "SELECT DISTINCT DAYOFMONTH(ziua) FROM rapoarte"; $ziuaResult = mysql_query($ziua);

With the results i get, i want to add them in a drop down box, like this: ` echo"Selectati Ziua:

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

echo"";

`

the problem is that my drop-down boxes are empty. there are 2, 3 options (depending on the select result), but no text is shown.

I have the same problem with this selection: SELECT DISTINCT HOUR(ora) FROM rapoarte

How can i fix this?

thanks, Sebastian

EDIT

sorry, i added the wrong code.


You are only selecting HOUR(ora) without the column ziua. The following should select the ziua column, unique by HOUR(ora).

SELECT DISTINCT HOUR(ora) AS something,ziua FROM rapoarte GROUP by something

If you turned error_reporting(E_ALL); on, you would see an error about an undefined index, ziua.


Should your argument passed to mysql_fetch_array() be $ziuaResult instead of $trunchiResult ?


this should work:

echo "<option value='".$trunchi1."'>".$trunchi1."</option>"; 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜