1

我尝试了很多事情,但我无法将选项的值设为数据库中的 id,并且我无法将选项写为数据库中的日期和标题,我目前正在这样做,任何帮助将不胜感激。

<select name="agenda "size="10">
            <?php
            global $connection;
            $result = mysql_query("SELECT * FROM agenda where date > now() order by date", $connection);
            $i = 0;
            while ($row = mysql_fetch_array($result) && $i < 20)
                {
                $id = $row['id_agenda'];
                $date = $row['date'];
                $title = $row['title'];
                //here i would like to make an option with 
                //value = id_agenda and write the date_agenda and title_agenda
                //something like this
                //<option value="$row[$id]">$date $title</option>
                $i++;
                }
            ?>
            <option value="Google">meeting 2</option>
        </select>
4

2 回答 2

1

采用:

echo "<option value=\"$id\">$date $title</option>";

于 2013-06-12T03:28:59.940 回答
0
while ($row = mysql_fetch_array($result)) {
    echo "<option value=\"$row[id_agenda]\">$row[date] $row[title]</option>";
}
于 2013-06-12T03:26:35.227 回答