使用php mysql标记系统[关闭]

I've some code here and I don't understand how to make this work:

$query = "SELECT * FROM `blog-posts` ORDER BY `date` DESC LIMIT 0, 10 WHERE `tags` LIKE '%test%'";
$result = mysql_query($query);

while($posts = mysql_fetch_array($result)) {
    echo $posts["title"] . "<br>";
    echo $posts["text"] . "<br>";
    $mydate = strtotime($posts["date"]);
    echo date('j M', $mydate) . "<br>";
    echo $posts["tags"] . "<br>";
    }
    echo "<a style=\"float:right;\" href=\"logout.php?action=logout\">Log out</a>";

Can somebody help me plz. Grts.

Your clauses in your MySQL query are in the wrong order, WHERE should come before both ORDER BY and LIMIT.

$query = "SELECT * FROM `blog-posts` WHERE `tags` LIKE '%test%' ORDER BY `date` DESC LIMIT 0, 10 ";

Beyond that there is not enough information in your question to figure out anything.

You have the wrong argument order in your query. WHERE needs to go before ORDER BY AND LIMIT.

$query = "SELECT * FROM `blog-posts` WHERE `tags` LIKE '%test%' ORDER BY `date` DESC LIMIT 0, 10";