I have a database setup where I can rank certain records, so when I query the database the records are displayed in order according to their rank. And if an record has a rank of 0 it isn't displayed. Simple enough... but I have come to a spot where I need to have some records be ranked the same.
This is fine because the rank is not the primary key. The problem that I am having is displaying the information.
What I have been doing in the past is displaying the Title and a Summary in a box and have them ordered by rank.
Now in some scenarios I give the same rank to more than one record and would like to display All titles that correspond to the rank to show up in one box along with one of the Summaries - most likely the one that relates to the first Title.
My first thought was to create a two-dimensional array and input all the data into it then list the info like this.
for ( $i=0; $i<$num_rows; $i++)
{
$row = mysql_fetch_array($result);
$data = array( array( rank => $row['rank'], title => $row['title'], summary => $row['summary'] ));
if ($data[$i]['rank'] == $data[$i++]['rank'])
{
echo "<p>".$data[$i]['title']."<br>\n";
echo $data[$i++]['title']."</p>\n";
} else {
echo "<p>".$data[$i]['title']."</p>\n";
}
}
But it doesn't work, and it loads VERY SLOOOOWLY.
If anyone has an idea that would be awesome.