Ok dzięki. Znalazłem coś dla mnie.
Mam jeszcze pytania dwa
1) jak zrobić aby on wyświetlał np: 3 ostatnie wiadomości.
albo
2) Jak zrobić aby pokazywal tylko tyle wiadomości ile zmieści się na wysokości height=250
<?php
/*
* Author: Rafael Rocha - www.projectrr.net - info@rafaelrocha.net
* <a href="http://www.projectrr.net/" target="_blank">http://www.projectrr.net/</a> -> scripts
* Date: 21.12.2009
* Version: 1.0
* License: LGPL
* News system
*
*/
require 'config.php';
function VerifyTxtFile(){
$file = fopen("content/coments.txt", "w"); }
return true;
}
function ReadNews(){
VerifyTxtFile();
$fh = fopen("content/news.txt", 'r'); return ExplodeNews($theData);
}
function ExplodeNews($NewsArray){
if($NewsArray == "") return 0;
$Coments = explode("<X-_-X>", $NewsArray); for($i=0; $i!=sizeof($Coments)-1; $i++){ $Coment = explode("<XXX_>", $Coments[$i]); $list[$i]['title'] = $Coment[0];
$list[$i]['date'] = $Coment[1];
$list[$i]['resumo'] = $Coment[2];
}
return $list;
}
function FindNew($id_new){
VerifyTxtFile();
$fh = fopen("content/news.txt", 'r'); $Coments = explode("<X-_-X>", $theData);
if($id_new < sizeof($Coments)-1 and
$id_new >= 0
){
$Coment = explode("<XXX_>", $Coments[$id_new]); $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
if(isset($_GET['view'])){ $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>";
if(isset($new_c['image'])){ $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 "<td><span class=\"NewsBody\">".$new_c['completo']."</span></td>";
</table>
<p> </p>";
}else{
echo "ERROR, no new found with id ".$_GET['id']; }
}else{
echo "<table width=\"100%\" border=\"0\"><tr> <td valign=\"top\">";
$all_news = ReadNews();
if($all_news != 0){
for($i = sizeof($all_news)-1; $i >= 0; $i--){ 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{
}
echo "</td></tr></table>"; }
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;
}
?>