July 20, 200818 yr This should be simple but I'm not quite there. I want to create a drop down list to link to sections on the same page. Here is what I have so far: function make_genera_pulldown() { // Make the genre array: $genera = array (1 => '', 'ACOUSTIC', 'ALTERNATIVE', 'BLUES ROCK', 'DRUM AND BASE', 'ELECTRO', 'EMO', 'EXPERIMENTAL', 'FOLK', 'FUNK', 'GARAGE', 'GOTHIC', 'GRUNGE', 'HARDCORE', 'HIP-HOP', 'INDIE', 'JAZZ', 'MAGOO', 'METAL', 'NEW WAVE', 'POWERPOP', 'PROGRESSIVE', 'PUNK', 'RNB', 'SKA', 'WRONGPOP'); // Make the genre pull-down menu: echo '<select name="genera">'; foreach ($genera as $key => $value) { echo '<option><a href="#'.$value.'">'.$value.'</a></option>'; } echo '</select>'; } ?> Genre: <?php make_genera_pulldown(); ?> require_once (MYSQL); // Connect to the db. $q = "SELECT band_id, genera, band_name, music_description FROM band_members ORDER BY genera , band_name"; $r = mysqli_query($dbc, $q); $currentGenre = ''; while ($messages = mysqli_fetch_array($r, MYSQLI_ASSOC)) { if ($currentGenre != $messages['genera']) { echo "<a name=\"{$messages['genera']}\"><h2>{$messages['genera']}</h2></a>\n"; $currentGenre = $messages['genera']; } echo "<a href=bandinfo.php?id={$messages['band_id']}><h5> ".stripslashes($messages ['band_name'])."</h5></a><br /> ".stripslashes($messages['music_description'])." <br /><br />\n"; } mysqli_free_result ($r); // Free up the resources. mysqli_close($dbc); // Close the database connection. But it not quite working yet. Thanks for any help...
Create an account or sign in to comment