• sheep630

    (@sheep630)


    $sqlsort = "select ID from wp_posts left join wp_postmeta on wp_postmeta.post_id=wp_posts.IDleft join wp_term_relationships on wp_term_relationships.Object_ID=wp_posts.IDleft join wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id= wp_term_relationships.term_taxonomy_idleft join wp_terms on wp_terms.term_id= wp_term_taxonomy.term_idwhereID` in (“.$rxt.”) and meta_key=’price_value’ group by ID order by meta_value;”;

    //echo $sqlsort.”<BR>”;
    $ressort = mysql_query($sqlsort);`

    The price sorting by meta_value is not corret.
    output order become (1000, 2050, 200, 300)

    I tried to replace the meta_value with meta_value_num, but an error message comes up. Can any one please suggest how to solve this issue.
    Thanks in advance!

Viewing 1 replies (of 1 total)
  • gaurabmani

    (@gaurabmani)

    you can grab the datas in an array and numerically sort it , then it will be arranged in the correct format.

    while($result = mysql_fetch_array($ressort)) {
    $meta_values[] = $result[‘price’];
    }
    sort($meta_values, SORT_NUMERIC);
    echo ‘

    ';
    print_r($n);
    echo '
    ';
    
    Is that one what you are looking for?

Viewing 1 replies (of 1 total)
  • The topic ‘Sorting by meta_value issue’ is closed to new replies.