I want to sort a results set, but the foreach() loop does not allow it the way it is presently constructed. Could use some help modifying it so the results set is sorted properly instead of cycling between the query and the display of results.
The following code comes after a block that finds appropriate records ($pcode) to display.
Note: To the end of the query, I have added an echo statement to show how the loop works now at the test site:
http://test.kripalu.org/search.php?s...note+worldwide
Here is the code:
PHP Code://pull out applicable records one at a time
foreach($found_present as $pcode) {
//dump out codes of purged list
//echo("<p>P Code: $pcode</p>");
//get the found presenters one at a time
$sql = "select
presenter.presenterid,
presenter.lastname,
presenter.firstname,
presenter.sanskritname
from
presenter
where
presenter.presenterid = '$pcode'
order by
presenter.lastname, presenter.firstname ";
echo("<p>SQL: $sql</p>");
//retrieves one record and builds a record set
$rsSearch = $db->query($sql);
if (mysql_num_rows($rsSearch)) {
while ($rowSearch = mysql_fetch_array($rsSearch)) {
?>
<!-- <p> -->
<?
//if any results, print links
?>
<a href="/presenter/<? echo($pcode); ?>/<? echo($_GET["s"]); ?> ">
<? echo(htmlentities($rowSearch["sanskrit"])); ?>
<? echo(htmlentities($rowSearch["firstname"])); ?>
<? echo(htmlentities($rowSearch["lastname"])); ?></a><br />
<?
}//end while
}//end numrows
}//end foreach





Bookmarks