Jump to content
php.lv forumi

problema ar limit?


Raimiks

Recommended Posts

Gribēju lai uz lapuses budu redzamas 3 pedejas ziņas. http://speedwaygp.lv/?page=news bet atēlo tikai pēdejo ?? Lūk koda gabals.

<?php

$result = mysql_query("SELECT * FROM $news order by news_dat desc LIMIT 3") or die(mysql_error());

while ($arr = mysql_fetch_array($result)) {

$title = $arr['news_title'];

$text = $arr['news_short_text'];

$dat = $arr['news_date'];

$content = '<table width=100% border=0 cellspacing=0 cellpadding=10 align=center style="border: #c47f2c 1px dashed;" height="100%">

<tr>

<td align=left><p align=justify><b>'.$title.'</b>

<hr align=left>

'.$text.'

<hr align=right>

<div align=right>Publicets: <i>'.$date.'</i></div></p></td>

</tr>

</table>

<br>';

 

}

?>

Link to comment
Share on other sites

luk bāzes kods viss itka norm??

CREATE TABLE `rus_news` (

`news_id` int(11) NOT NULL auto_increment,

`news_title` tinytext NOT NULL,

`news_dat` tinytext NOT NULL,

`news_short_text` mediumtext NOT NULL,

`news_full_text` longtext NOT NULL,

PRIMARY KEY (`news_id`)

) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=5 ;

 

--

-- Дамп данных таблицы `rus_news`

--

 

INSERT INTO `rus_news` (`news_id`, `news_title`, `news_dat`, `news_short_text`, `news_full_text`) VALUES

(1, 'последние новости', '12.02.2007', 'на данный момент работают разделы спонсоры ссылки главная контакты', 'Сайт в стадии разработки astalnoje pozhe'),

(2, 'последние новости2', '12.02.2007', 'TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST', 'Сайт в стадии разработки astalnoje pozhe'),

Link to comment
Share on other sites

Raimiks, par . pirms = neaizmirsi ?

Ā, un jā - pamēģini arī:

$result = mysql_query("SELECT * FROM $news order by news_dat desc LIMIT 3") or die(mysql_error());
echo mysql_num_rows($result);

 

Pasaki, ko izdrukāja.

Edited by andrisp
Link to comment
Share on other sites

<?php
error_reporting(E_ALL);
$news=mysql_escape_string($news); //Prezumeejot, ka $news *netiek* valideets un ir user inputs 
$result = mysql_query("SELECT news_title, news_short_text, news_date FROM $news order by news_dat desc LIMIT 3") or die(mysql_error());
$content = ""; 
while ($arr = mysql_fetch_assoc($result)) {
$content = .'<table width=100% border=0 cellspacing=0 cellpadding=10 align=center style="border: #c47f2c 1px dashed;" height="100%">
<tr> 
<td align=left><p align=justify><b>' . $arr['news_title'] . '</b>
<hr align=left>
' . $arr['news_short_text'] . '
<hr align=right>
<div align=right>Publicets: <i>' . $arr['news_date'] . '</i></div></p></td>
</tr>
</table>
<br>';

}
?>

Edited by Ghenis
Link to comment
Share on other sites

×
×
  • Create New...