0
我需要一些帮助在选项值中使用函数。 我刚开始使用/学习功能,并写了这一点:如何在选择输入类型中使用函数
*function selectNew($dbcon) {
$sql = 'SELECT id, item, comment, date, time, important FROM item ORDER BY ASC id';
foreach ($dbcon->query($sql) as $row) {
print $row['item'] . "\t";
print $row['comment'] . "\t";
print $row['date'] . "\n";
print $row['time'] . "\n";
print $row['important'] . "\n";
}
}*
我想使用这个在:如果我选择这
<table>
<tr><th>Select by:</th><td><select>
<option value="<?php selectNew ?>">Newest</option>
</select></td></tr>
</table>
我想呼应,从我的数据库升序排列数据ID。
这是可能的还是我需要以其他方式做到这一点?
谢谢,
您的函数可能会返回多行。同样在你的用例中,你不能在value属性中放置多个值,更不用说多行了。 –
使用phpAdmin运行您的查询,然后查看结果。此外,创建您期望看到的纯HTML结果(而不是您使用函数调用显示的结果)。最后,由于你正在学习,你应该认识到,当你调用函数时,你需要传递函数声明中指定的参数。 –
谢谢,我在phpmyadmin中试过了,发现问题了! – Youri