Hi all. I just started programming 5 days ago. I had a quick question and I was option you could help.
I'm trying to convert the script below into a function so I can throw it into an include file and use it over and over again. How would I go about doing that and returning the proper optionbox html? I've looked at many examples, but none seem to help. Thanks in advanced!
<?php
session_start();
if(!isset($_SESSION['user_admin'])) {
header("Location: index.php");
exit();
}
include '../../dbc.php';
$genre_query="SELECT * FROM genres ORDER BY name";
$genre_result=mysql_query($genre_query);
$genre_num=mysql_numrows($genre_result);
$optionbox_return = "";
echo "<SELECT name=\"band_genre_1\", id=\"band_genre_1>\"";
$i=1;
while ($i < $genre_num) {
$optionbox_genre_name=mysql_result($genre_result,$i,"name");
$optionbox_genre_id=mysql_result($genre_result,$i,"id");
$option_text = $optionbox_genre_name;
echo $option_text;
echo "<OPTION value=\"$optionbox_genre_id\">$option_text</OPTION>";
$i++;
}
echo "</SELECT>";
?>