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

Categories

0 votes
530 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...