I wonder whether someone can help me please.
I've put together the script below that displays a list of dates from a mySQL database.
<?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>
What I'd now like to do is upon a date being selected, retrieve the associated values from the fields 'findname' and 'finddescription, inserting them in a table on my page.
I've spent hours trying to get this to work, without any success. I just wondered whether someone could perhaps give me a helping hand please and let me know what I need to do to retrieve the results.
Many thanks
Updated Code
<?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>