I have now spent well over 12 hours on this one problem.
I am pulling data out of a database, the data in the database is categorized by a value (season).
I need to title the first value, then echo the listings that would fall into that category. Once this is completed I need to then label the next value and echo the values that would fall into that category... so on and so forth..
this is concept I have had so far:
include("./include/db.inc.php");
$sql = "SELECT * FROM table WHERE view=1 ORDER BY file";
$result = mysql_query($sql, $dbconn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {
$id = $newArray['id'];
$season = $newArray['season'];
$file = $newArray['file'];
$name = $newArray['name'];
$history = $newArray['history'];
$view = $newArray['view'];
if ($season == "0") {
echo "<b>--- Pre-Season ---</b><br/>";
echo "<a href=\"images/$file.jpg\">$name</a><br/>\n";
}
if ($season == "1") {
echo "<b>--- 1st Season ---</b><br/>";
echo "<a href=\"images/$file.jpg\">$name</a><br/>\n";
}
if ($season == "2") {
echo "<b>--- 2nd Season ---</b><br/>";
echo "<a href=\"images/$file.jpg\">$name</a><br/>\n";
}
}
?>
The output I get from this is:
<b>--- Pre-Season ---</b><br/>
<a href=\"images/value1-file.jpg\">value1-name</a><br/>
<b>--- Pre-Season ---</b><br/>
<a href=\"images/value2-file.jpg\">value2-name</a><br/>
<b>--- Pre-Season ---</b><br/>
<a href=\"images/value3-file.jpg\">value3-name</a><br/>
<b>--- 1st Season ---</b><br/>
<a href=\"images/value4-file.jpg\">value4-name</a><br/>
<b>--- 1st Season ---</b><br/>
<a href=\"images/value5-file.jpg\">value5-name</a><br/>
<b>--- 2nd Season ---</b><br/>
<a href=\"images/value6-file.jpg\">value6-name</a><br/>
<b>--- 2nd Season ---</b><br/>
<a href=\"images/value7-file.jpg\">value7-name</a><br/>
What I was expecting was:
<b>--- Pre-Season ---</b><br/>
<a href=\"images/value1-file.jpg\">value1-name</a><br/>
<a href=\"images/value2-file.jpg\">value2-name</a><br/>
<a href=\"images/value3-file.jpg\">value3-name</a><br/>
<b>--- 1st Season ---</b><br/>
<a href=\"images/value4-file.jpg\">value4-name</a><br/>
<a href=\"images/value5-file.jpg\">value5-name</a><br/>
<b>--- 2nd Season ---</b><br/>
<a href=\"images/value6-file.jpg\">value6-name</a><br/>
<a href=\"images/value7-file.jpg\">value7-name</a><br/>
Thank you for all your help in advance...
(sorry if this doesn't make sense - the past 12 straight hours have been trying to figure this out)