|
|
|
| Здравствуйте.
<?php
include_once('db_fns.php');
include_once('header.php');
$handle = db_connect();
$pages_sql = 'select * from pages order by code';
$pages_result = $handle->query($pages_sql);
echo "<td background=\"images/bg_c1.gif\" ><br>
<img src=\"images/trans.gif\" ><br>
<div style=\"width: 100%\" align=\"center\">";
$pages = $pages_result->fetch_assoc();
$story_sql = "select * from stories
where page = '{$pages['code']}' // здесь он выбирает последнюю новость
and published is not null // а как сделать чтобы были последние 5
order by published desc"; // новостей
$story_result = $handle->query($story_sql);
if ($story_result->num_rows) {
$story = $story_result->fetch_assoc();
echo "<h2 >{$pages['description']}</h2>
{$story['headline']}
<p align='right' class='morelink'>
<a href='page.php?page={$pages['code']}'>
×èòàòü äàëüøå {$pages['descriptions']} ...
</a>
</p>
</div>
</td> ";
echo " </tr></table></td></tr>";
}
include_once('footer.php');
?>
|
| |
|
|
|
|
|
|
|
для: dream-x
(19.08.2008 в 13:12)
| | А вопрос какой?
PS Для того, чтобы выводилось только 5 сообщений следует исправить запрос следующим образом
select * from pages order by code limit 5
|
Чтобы сообщения были последними нужно больше информации о таблице и структуре записей. | |
|
|
|
|
|
|
|
для: dream-x
(19.08.2008 в 13:12)
| |
$story_sql = "select * from stories
where page = '{$pages['code']}' // здесь он выбирает последнюю новость
and published is not null // а как сделать чтобы были последние 5
order by published desc LIMIT 5";
|
| |
|
|
|