Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

Problem with PHP printing in drop down box

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...