Read php function into drop down box
9 hours ago, Bigun said:Is that returning anything? AFAIK, the value collected there should be the result of the query, not the actual data,
print_r($selectGold);
But if your sure of that, I'll move on.
Are you wanting sub-selections in the dropdown box with a "Gold Medalist" divider? If so, it can be accomplished one of two ways:
- No Javascript - run query at beginning of page load, then populate menu with some embedded PHP looping
- With javascript - Kinda covered in Hazy's post
pretty much all i'm looking to accomplish is have my queries related to the drop down items, so one will be gold medalist another silver etc and when i press gold I want it to display all the gold medalists in the database.
edit: so heres a query i want to list all the sports in the database:
$selectSports = "Select sport FROM AthleteTable";
$sports = $pdo->query($selectSports);
and then i tried to foreach through and print them into the drop down box:
<select name=Sports> <?php foreach($sports as $row) { ?> <option value="<?php echo $row['sport'];?>"><?php $row[sport]; ?></option> </select> <?php } ?>
but the drop down box is still empty, any idea what i've done wrong here?
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now