Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a mysql query:

$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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
520 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...