【发布时间】:2012-03-03 15:33:54
【问题描述】:
我想知道是否有人可以帮助我。
我将下面的脚本放在一起,显示来自 mySQL 数据库的日期列表。
<?php
mysql_connect("host", "user", "password")or
die(mysql_error());
mysql_select_db("database");
?>
<form>
<select>
<?php
$result = "SELECT userdetails.userid, finds.dateoftrip, detectinglocations.locationname, finds.findid, finds.userid, finds.locationid, detectinglocations.locationid, finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1 GROUP By dateoftrip ORDER BY dateoftrip DESC";
$result =mysql_query($result);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $data['findid'] ?>" ><?php echo $data['dateoftrip'] ?></option>
<?php } ?>
</select>
</form>
我现在想做的是在选定日期后,从“findname”和“finddescription”字段中检索相关值,并将它们插入到我页面上的表格中。
我花了几个小时试图让它工作,但没有任何成功。我只是想知道是否有人可以帮我一把,让我知道我需要做什么来检索结果。
非常感谢
更新代码
<?php
mysql_connect("host", "user", "password")or
die(mysql_error());
mysql_select_db("database");
?>
<form>
<select>
<?php
$result = "SELECT dateoftrip, findid, userid, locationid, findname, finddescription FROM finds GROUP By dateoftrip ORDER BY dateoftrip DESC";
$result =mysql_query($result);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $data['findid'] ?>" ><?php echo $data['dateoftrip'] ?></option>
<?php } ?>
</select>
</form>
【问题讨论】:
-
您的选择查询中没有 findid。
-
我不确定我是否理解您的问题。你有这个下拉菜单,根据用户的选择,你需要从你的 bd 中检索一些数据?
-
两者,抱歉,我已经修改了我的帖子以更准确。亲切的问候