WordPress.org

Ready to get started?Download WordPress

Forums

POD CMS sort codes (6 posts)

  1. AcidRainZ
    Member
    Posted 3 years ago #

    Guy can you help me out with my codes?the current codes sort thing alphabetically.I want it to be sorted by the highest score to the lowest 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.";
    		}
    	}
    ?>
  2. AcidRainZ
    Member
    Posted 3 years ago #

    Please help me with this one

  3. Scott Kingsley Clark
    Member
    Posted 3 years ago #

    Try switching out your $params['select'] line to this one:

    $params['select'] = 't.score DESC, t.name, t.date_played';

  4. AcidRainZ
    Member
    Posted 3 years ago #

    tabs][tab title="Song Info"] Song Title: Bridal March Source: G Major Music Genre: Synthesia Pack Level 0.0 Description: This piece is included in the original collection of pieces included when you download Synthesia. We have included them on our site as well so that you can get points for completing those pieces as well as ours. [/tab] [tab title="Download"] [box type="alert"] There is no download link because this piece is included with your Synthesia download. [/box][/tab] [tab title="Top Scores"]
    SQL failed; SQL: SELECT SQL_CALC_FOUND_ROWS DISTINCT t.name DESC,t.score, t.date_played FROM wp_pod p INNER JOIN wp_pod_tbl_song_scores t ON t.id = p.tbl_row_id WHERE p.datatype = 4 AND ( t.song_url LIKE "%bridal-march%" ) ORDER BY t.id DESC LIMIT 0,10; Response: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC,t.score, t.date_played FROM wp_pod p ' at line 2

  5. Scott Kingsley Clark
    Member
    Posted 3 years ago #

    Sorry, my mistake. I was using your code in the wrong way.

    Try this:

    $params['orderby'] = 't.score DESC, t.name, t.date_played';

  6. AcidRainZ
    Member
    Posted 3 years ago #

    thanks alot scott big help

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags