This is the code right here. I cant fix this thing. Please help
<?php
$strNewsQuery = '
SELECT TOP 15
N.[title],
C.[title] AS category,
C.[icon] AS icon,
N.[datetime],
N.[forenlink],
N.[text]
FROM [' . $_CONFIG['db_databases']['web'] . '].[dbo].[web_news] AS N
LEFT JOIN [' . $_CONFIG['db_databases']['web'] . '].[dbo].[web_newscategories] AS C ON C.ncatid = N.category
ORDER BY nid DESC
';
$dbNewsQuery = @odbc_exec($odbc_connect, $strNewsQuery);
if(@odbc_num_rows($dbNewsQuery) > 0) {
while($mixedNewsEntry = @odbc_fetch_array($dbNewsQuery)) {
echo '
<div class="media-box">
<div class="content-img">
<span><img height="190px" width="190px" src="images/icons/news/'.$mixedNewsEntry['icon'].'></span>
</div>
<div class="con-header">
' . $mixedNewsEntry['title'] . '
</div>
<div class="content-media">
' . nl2br($mixedNewsEntry['text']) . '
' . $_LANG['publish_date'] . ': ' . date($_CONFIG['web_date_format']['full'], strtotime($mixedNewsEntry['datetime'])) . ' ' . $_LANG['oclock_optional'] . '
</div>';
if(!empty($mixedNewsEntry['forenlink'])) {
echo '
<div ad-content>
' . $_LANG['news_link_to_forum'] . ': <a href="' . htmlspecialchars($mixedNewsEntry['forenlink']) . '" title="Forum" target="_blank">READ MORE>>></a>.
</div>';
}
echo '
</div>';
}
}
else {
echo createMessage($_LANG['no_entry'], 'hint');
}
?
How can i limit this sql into 5 i tried the "limit 0,5" method at the end of "ORDER BY nid DESC" does not work and tried other methods like java syntax
最佳答案
将选择前 15 名
更改为选择前 5 名
关于php - 限制sql php中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49381506/