Hey all
Basically, I am outputting a list of data from my MySQL database, and want to ALWAYS exclude the first two results.
Any way to do this?
If you are showing on a php page you can just skip the first two using the result.
Or
http://us2.php.net/manual/en/function.mysql-data-seek.php
Which you can use to skip a couple results returned.
Yes I am using it on a PHP page. How do you do this skip?
You could use a counter $counter = 0; and in the loop do $counter++; If the counter is greater than 2 then show the results.
Erm, I'm a bit of a novice here lol
Here is what I have currently. Where do I add this in?
$result = mysql_query("
SELECT
gamecms_article.gameId,
gamecms_article.articleId,
gamecms_article.timestamp,
gamecms_article.categoryId,
gamecms_articleRatings.articleId,
gamecms_articleRatings.ratingId,
gamecms_articleRatings.ratingText,
gamecms_articleRatings.rating,
gamecms_game.gameId,
gamecms_game.gameName,
gamecms_game.systemId
FROM
gamecms_article
LEFT JOIN
gamecms_articleRatings
ON
gamecms_article.articleId = gamecms_articleRatings.articleId
LEFT JOIN
gamecms_game
ON
gamecms_article.gameId = gamecms_game.gameId
WHERE ratingId='1'
AND systemId='1'
AND categoryId='1'
ORDER BY timestamp DESC
LIMIT 5");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
print
"<tr><td>
<center><a href = 'http://www.euronintendo.co.uk/review.php?articleId=".$row{'articleId'}."&page=1'><b class='style2'>".$row{'gameName'}."</b></a></center>
</td><td width='50px'>
<center>".$row{'rating'}."%</center>
</td></tr>";
}
?>
Not a SQL expert but can you not just use OFFSET?
Try this
$result = mysql_query("
SELECT
gamecms_article.gameId,
gamecms_article.articleId,
gamecms_article.timestamp,
gamecms_article.categoryId,
gamecms_articleRatings.articleId,
gamecms_articleRatings.ratingId,
gamecms_articleRatings.ratingText,
gamecms_articleRatings.rating,
gamecms_game.gameId,
gamecms_game.gameName,
gamecms_game.systemId
FROM
gamecms_article
LEFT JOIN
gamecms_articleRatings
ON
gamecms_article.articleId = gamecms_articleRatings.articleId
LEFT JOIN
gamecms_game
ON
gamecms_article.gameId = gamecms_game.gameId
WHERE ratingId='1'
AND systemId='1'
AND categoryId='1'
ORDER BY timestamp DESC
LIMIT 5");
$counter = 0;
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$counter++;
if ($counter < 2)
continue;
print
"<tr><td>
<center><a href = 'http://www.euronintendo.co.uk/review.php?articleId=".$row{'articleId'}."&page=1'><b class='style2'>".$row{'gameName'}."</b></a></center>
</td><td width='50px'>
<center>".$row{'rating'}."%</center>
</td></tr>";
}
?>
Fantastic
Thank you so much :)