AcidRainZ Posted May 17, 2011 Share Posted May 17, 2011 Please help guys on the codes i want to sort the list to highest scores to the lowest.it is currently sorting by name not by scores heres the code: <?php $scores = new Pod("song_scores"); $whichsong = pods_url_variable('last'); $params = array(); $params['select'] = 't.name, t.score, t.date_played'; $params['where'] = 't.song_url LIKE "%'.$whichsong.'%"'; $params['limit'] = 10; $scores->findRecords($params); $total_scores = $scores->getTotalRows(); ?> <?php if($whichsong == "" || (strlen($whichsong)<3)){ echo '<div id="top-score">'; echo "This tab displays scores only in the individual songs page."; echo '<br />Please click <a href="'; $permalink = the_permalink(); echo '">here</a> to view the scores.'; echo '</div>'; } else{ if($total_scores>0){ echo '<div id="top-score">'; echo '<div id="top-score-header"><div class="top-score-name">Name</div><div class="top-score-score">Score</div><div class="top-score-date">Date Played</div></div>'; echo '<ol>'; while ( $scores->fetchRecord() ) { echo '<li><div class="top-score-name"><a href="/members/'. $scores->get_field("name") .'/profile/">' . $scores->get_field("name") . '</a></div><div class="top-score-score">' . $scores->get_field("score") . '</div><div class="top-score-date">' . $scores->get_field("date_played") . '</div>'; } echo "</ol>"; echo "</div>"; } else{ echo "No scores for this song has been uploaded yet."; } } ?> MOD EDIT: code tags added. Quote Link to comment Share on other sites More sharing options...
fugix Posted May 17, 2011 Share Posted May 17, 2011 in your query why dont you add an ORDER by t.score DESC clause Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 17, 2011 Share Posted May 17, 2011 When posting code, enclose it in . . . BBCode tags. Quote Link to comment Share on other sites More sharing options...
AcidRainZ Posted May 17, 2011 Author Share Posted May 17, 2011 sorry mods it will not happen again where will i put the query string? Quote Link to comment Share on other sites More sharing options...
fugix Posted May 17, 2011 Share Posted May 17, 2011 Well in your $params array it looks like you are building a mysql query but you never actually call it in the code that you have posted Quote Link to comment Share on other sites More sharing options...
AcidRainZ Posted May 17, 2011 Author Share Posted May 17, 2011 so in anyway can we implement the order by codes in the param? Quote Link to comment Share on other sites More sharing options...
AcidRainZ Posted May 18, 2011 Author Share Posted May 18, 2011 please help me out with this guys Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 18, 2011 Share Posted May 18, 2011 Did you write the code in the OP? Quote Link to comment Share on other sites More sharing options...
AcidRainZ Posted May 18, 2011 Author Share Posted May 18, 2011 OP? im using it under wordpress platform Quote Link to comment Share on other sites More sharing options...
pornophobic Posted May 18, 2011 Share Posted May 18, 2011 OP? Original Post. im using it under wordpress platform I don't mean to sound rude or anything, but you might be creating more work for yourself than you need to be if you're building something into wordpress... wordpress platform. Did you RTFM? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.