Czy ktoś potrafiłby dla mnie wyciągnąc z tego skryptu aktualności możliwość wyświetlenia np: tylko 3 ostatnich wpisów?
Prosze o napisania kodu.
<?php require 'config.php'; function VerifyTxtFile(){ } return true; } function ReadNews(){ VerifyTxtFile(); return ExplodeNews($theData); } function ExplodeNews($NewsArray){ if($NewsArray == "") return 0; $list[$i]['title'] = $Coment[0]; $list[$i]['date'] = $Coment[1]; $list[$i]['resumo'] = $Coment[2]; } return $list; } function FindNew($id_new){ VerifyTxtFile(); $new['title'] = $Coment[0]; $new['date'] = $Coment[1]; $new['completo'] = $Coment[3]; if($Coment[4] != ""){ $new['image'] = $Coment[4]; $new['align'] = $Coment[5]; } }else{ return 0; } return $new; } ?> <link rel="stylesheet" type="text/css" href="images/style.css" /> <?php $new_c = FindNew($_GET['id']); if($new_c != 0){ echo "<table width=\"100%\" border=\"0\"> <tr> <td height=\"20\"><strong><p class=\"NewsTitle\">".$new_c['title']."</p></strong></td> </tr> <tr> <td height=\"20\" class=\"NewsBody\"><strong>".$new_c['date']."</strong></td> </tr> <tr>"; $size = RedimensionaImagem("images/".$new_c['image']); echo "<td><img style=\"margin-left: 5px; margin-right: 5px;\" src=\"images/".$new_c['image']."\" align=\"".$new_c['align']."\" width=\"".$size['largura']."\" height=\"".$size['altura']."\" class=\"images\" ><span class=\"NewsBody\">".$new_c['completo']."</span></td>"; }else echo "</tr> </table> <p> </p>"; }else{ } }else{ $all_news = ReadNews(); if($all_news != 0){ echo "<table width=\"100%\" border=\"0\" align=\"center\"> <tr> <td height=\"15\" class=\"NewsTitle\"><strong><a href=\"?view&id=".$i."\">".$all_news[$i]['title']."</a></strong></td> </tr> <tr> <td height=\"15\" class=\"NewsBody\"><strong>".$all_news[$i]['date']."</strong></td> </tr> <tr> <td class=\"NewsBody\">".$all_news[$i]['resumo']."</td> </tr> </table><p> </p>"; } }else{ } } function RedimensionaImagem($imagem){ $height = $size[1]; $width = $size[0]; if ($height > __MAXHEIGHT) { $height = __MAXHEIGHT; $percent = ($size[1] / $height); $width = ($size[0] / $percent); } else if ($width > __MAXWIDTH) { $width = __MAXWIDTH; $percent = ($size[0] / $width); $height = ($size[1] / $percent); } $tamanho['largura'] = (int) $width; $tamanho['altura'] = (int) $height; } return $tamanho; } ?>