Hi All: I am new to creating arrays and am trying to create a variable to hold a list of items and print it multiple times on a page. Below is the PHP that I've attempted and below that is the HTML which shows the same SELECT list multiple times on the page. It is only listing the first item in the SELECT list. Other tweaks have resulted in the SELECT list having the complete list of items from the database, but any other calls to this variable elsewhere on the page fails.
What can I do to get a variable to hold this SELECT list so that I can print it multiple times on the page?
<?php
$catresult = mysql_query("SELECT * FROM Classes WHERE FK_UserID=$_SESSION[user_id] ORDER BY ClassName");
$dataset = array();
while($row = mysql_fetch_array($catresult)) {
$dataset = '<option value="' . $row['ClassID'] . '">' . $row['ClassName'] . '</option>';
}
?>
<!-- HTML below -->
Paragraph 1 content...
<select name="FK_ClassID" /><option value="">Class</option><?php echo $dataset; ?></select>
Paragraph 2 content...
<select name="FK_ClassID" /><option value="">Class</option><?php echo $dataset; ?></select>
Paragraph 3 content...
<select name="FK_ClassID" /><option value="">Class</option><?php echo $dataset; ?></select>