0

我有以下 MySQL 查询,我想在满足条件时回显特定行;

global $post;
$post_author = $post->post_author;
$result = mysql_query("SELECT *, @rownum := @rownum + 1 from
    (
    SELECT (display_name) 'Author',
        IFNULL(ROUND(SUM(balance.meta_value),2),2) 'Balance'
    FROM posts p
    JOIN users u 
        ON p.post_author = u.ID
    JOIN postmeta odd ON p.ID = odd.post_id AND odd.meta_key = 'odd' AND odd.meta_value >= 1.5
    LEFT JOIN postmeta balance 
        ON p.ID = balance.post_id AND balance.meta_key = 'balance'
    WHERE p.post_status = 'publish'
    GROUP BY u.ID
    ORDER BY Balanco DESC
    )x, (SELECT @rownum := 0) r");
$row = mysql_fetch_array($result);

当作者等于 $post_author 时,我想回显第 3 行,有人可以帮我解决这个问题。谢谢。

<?php echo "{$row[3]}";?> where Author=$post_author
4

1 回答 1

1

我相信一个简单的if会让你开心:

if ($row[0] == $post_author)
    echo $row[3];
于 2013-06-24T13:17:18.223 回答