Raimiks Posted February 12, 2007 Report Share Posted February 12, 2007 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 More sharing options...
andrisp Posted February 12, 2007 Report Share Posted February 12, 2007 1) kodu liec iekš paste.php.lv vai ari code tagos. 2) Kodā it kā viss ir daudzmaz ok. Pārliecinies vai tabulā pa tiešām ir vairāki tie ieraksti. Link to comment Share on other sites More sharing options...
Raimiks Posted February 12, 2007 Author Report Share Posted February 12, 2007 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 More sharing options...
4e4en Posted February 12, 2007 Report Share Posted February 12, 2007 (edited) varbūt vajag šitā?? $result = mysql_query("SELECT * FROM `$news` order by `news_id` desc LIMIT 0,3;"); if(!$result){ die(mysql_error()); } Edited February 12, 2007 by 4e4en Link to comment Share on other sites More sharing options...
Raimiks Posted February 12, 2007 Author Report Share Posted February 12, 2007 nē nesanāca :( rezultāta nava :( Link to comment Share on other sites More sharing options...
4e4en Posted February 12, 2007 Report Share Posted February 12, 2007 Ieteiktu sākt ar kādu grāmatiņu par PHP drošību, jo es tev uzraku nevienu vien SQL injekciju :) Link to comment Share on other sites More sharing options...
andrisp Posted February 12, 2007 Report Share Posted February 12, 2007 Ahh.. skaidrs tagad. Tu $content mainīgajam visulaiku pāraksti pāri. Pirms while izdari: $content = ''; un iekš while tur kur $content = 'html kods'; dari šādi: $content .= 'html kods'; Link to comment Share on other sites More sharing options...
Raimiks Posted February 12, 2007 Author Report Share Posted February 12, 2007 Nevajag taisīt muļķīgas QUOTEs (bubu) neiet cauri.. tas pats ka bija arī palika :( kadas vel ir idejas.. kur mūsu gaišie prāti??? Link to comment Share on other sites More sharing options...
4e4en Posted February 12, 2007 Report Share Posted February 12, 2007 pamēģini pēc $result = ... izdrukāt mysql_count vai numrows kautko tādu un aiz while(...) { var_dump($arr); ... Link to comment Share on other sites More sharing options...
andrisp Posted February 12, 2007 Report Share Posted February 12, 2007 (edited) 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 February 12, 2007 by andrisp Link to comment Share on other sites More sharing options...
Raimiks Posted February 12, 2007 Author Report Share Posted February 12, 2007 Nevajag taisīt muļķīgas QUOTEs (bubu) ta.. ne viens variant neizgaja :( neko nerakstija.. :( Link to comment Share on other sites More sharing options...
andrisp Posted February 12, 2007 Report Share Posted February 12, 2007 Kā neko ? Pat 1 ne ? Paskaties kārtigi. Tu kaut ko jaucies. Link to comment Share on other sites More sharing options...
bubu Posted February 12, 2007 Report Share Posted February 12, 2007 Vai datubāzes tabulā ir vispār vairāk kā viens ieraksts? Link to comment Share on other sites More sharing options...
Raimiks Posted February 12, 2007 Author Report Share Posted February 12, 2007 Nevajag taisīt muļķīgas QUOTEs (bubu) 4 ieraksti.. Link to comment Share on other sites More sharing options...
Ghenis Posted February 14, 2007 Report Share Posted February 14, 2007 (edited) <?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 February 14, 2007 by Ghenis Link to comment Share on other sites More sharing options...
Recommended Posts