Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Large data in database is the problem 95% ! - try using <code>limit x,y</code> in your queries , and put those queries in some loop . - see <a href="http://php.net/manual/en/function.mysql-free-result.php" rel="nofollow">http://php.net/manual/en/function.mysql-free-result.php</a> it might help</p> <pre><code>&lt;?php $participating_swimmers = array(); $event_standings = array(); $qualifying_times = array(); $select_times_sql = "SELECT * FROM demo_times_table WHERE sex = 'M' ORDER BY time ASC"; $select_times_query = mysql_query($select_times_sql); while ($select_times_row = mysql_fetch_assoc($select_times_query)) { //Create array with the current line's swimmer's info $swimmer_info["time"] = $select_times_row['time']; $swimmer_info["name"] = $select_times_row['name']; $swimmer_info["year"] = $select_times_row['year']; $swimmer_info["team"] = $select_times_row['team']; $swimmer_info["time_standard"] = $select_times_row['time_standard']; $swimmer_info["date_swum"] = $select_times_row['date_swum']; //Create "Top 8" list - if more than 8 A cuts, take them all if (($swimmer_info["time_standard"] == "A") || ($swimmer_info["time_standard"] == "B")) { //Check if there are 8 or less entries in the current event, or if the swim is an A cut if ((count($event_standings[$current_event]) &lt; 8) || ($swimmer_info["time_standard"] == "A")) { //Add swimmer to the list of invites $event_standings[$current_event][] = $swimmer_info; //Keep only the identifying information about the swimmer $condensed_swimmer_info["name"] = $swimmer_info["name"]; $condensed_swimmer_info["year"] = $swimmer_info["year"]; $condensed_swimmer_info["team"] = $swimmer_info["team"]; //Check if swimmers name already appears in list if (!in_array($condensed_swimmer_info, $participating_swimmers)) { //It is a unique user - add them to the list $participating_swimmers[] = $condensed_swimmer_info; } } else { //Add the qualifying time that did not fit into the list to a list of qualifying times $qualifying_times[$current_event][] = $swimmer_info; } } } mysql_free_result($select_times_query); //Sort each array of times in descending order arsort($event_standings); arsort($qualifying_times); $num_of_swimmers = count($participating_swimmers); $sql = "SELECT DISTINCT(event) FROM demo_times_table WHERE sex = 'M' limit 80"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)) { $loe = $row['event']; $num_of_qualifying_times = count($qualifying_times[$loe]); $event_standings[$loe][] = $qualifying_times[$loe][$num_of_qualifying_times-1]; //Keep only the identifying information about the swimmer $condensed_swimmer_info["name"] = $qualifying_times[$loe][$num_of_qualifying_times]["name"]; $condensed_swimmer_info["year"] = $qualifying_times[$loe][$num_of_qualifying_times]["year"]; $condensed_swimmer_info["team"] = $qualifying_times[$loe][$num_of_qualifying_times]["team"]; //Check if swimmers name already appears in list if (!in_array($condensed_swimmer_info, $participating_swimmers)) { //It is a unique user - add them to the list $participating_swimmers[] = $condensed_swimmer_info; } //Remove time from array of qualifying times unset($qualifying_times[$loe][$num_of_qualifying_times-1]); } $num_of_swimmers = count($participating_swimmers); mysql_free_result($query); arsort($event_standings); arsort($qualifying_times); $sql = "SELECT DISTINCT(event) FROM demo_times_table WHERE sex = 'M'"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)) { $loe = $row['event']; echo "&lt;h1&gt;".$loe."&lt;/h1&gt;&lt;br /&gt;"; foreach ($event_standings[$loe] as $es) { echo $es["time"]." ".$es["name"]." ".$es["team"]."&lt;br /&gt;"; } } /* foreach ($participating_swimmers as $ps) { echo $ps["name"]."&lt;br /&gt;&lt;br /&gt;"; } echo "&lt;br /&gt;&lt;br /&gt;"; */ ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload