0

Hi


I have some code that I have written that pulls out data from a simple database into a dropdown menu.

<?php
mysql_connect('localhost' , 'databasename', 'password');
mysql_select_db('databasename');
$result=mysql_query("SELECT * FROM Persons");
if(mysql_num_rows($result)>0)
{
?>
<select name="Persons">
<?php
while($rows=mysql_fetch_array($result)){
?>
<option value="<?php echo $rows; ?>"> <?php echo $rows; ?></option>
<?php
}
?>
</select>
<?php
}


I would like to update this to a jump menu so that if one of the items of data is selected the user is taken to a page showing all the data from the database about that record.

So I need a form script and a results page please....

All help appreciated.

Many thanks
Steve

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by diafol
0

Thank you - I've had a play with that today, but can't seem to get it working at all. eg. I'm not getting the user to be sent to the next page of information about the item they selected in the menu.....

I assume this must be a fairly frequently asked question, but I can't see any examples on the site here anywhere?

All help appreciated!

0

if you want a simple sol:

<script>
function jump(param){
    var indx  = param.selectedIndex;
    var selVal = param.options[indx].value;
    var url  = selVal + '.php';
    window.location.href = url;
    return true;
}
</script>

...

<select name="myselect" onchange="jump(this.form.myselect);">
  <option value="index">Home</option>
  <option value="profile">User Profile</option>
  <option value="contact">Contact Us</option>
</select>

not tested

Edited by diafol: n/a

0

Thanks, but I'm unsure how this fits in with my code and how to integrate the two...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.