chat

mam chat cez open file system nie cez databazu..ako by som urobil aby sa zobrazilo len 15 prispevkov?diky


if($n=="1"){
if($meno){
$old = fread(fopen("chata.txt","r"),filesize("chata.txt"));
$news = date ("d.n.y").", ".date("H:i")." (<i>$meno) prisiel</i><br/>\n";
$old = $news.$old;
$f = fopen("chata.txt","w");
fputs($f,$old);
fclose($f);
}
if($meno && $texte){
$texte=strip_tags($texte);
$old = fread(fopen("chat.txt","r"),filesize("chat.txt"));
$news = date ("d.n.y").", ".date("H:i")." (<b>$meno</b>) $texte<br/>\n";
$old = $news.$old;
$f = fopen("chat.txt","w");
fputs($f,$old);
fclose($f);
}
to je zapisovanie prispevkov
$filename = "./text.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd, 1500);
fclose ($fd);
echo"$contents";
pokud ti jde jen o zobrazeni poslednich 15 prispevku (zalezi jak to zapisujes - jestli cpes v txt souboru nove prispevky na zacatek souboru anebo na konec a pak to obracis) tak to muze vypadat nejak takhle


<?php
$s = file("chata.txt");
for ($i=0;$i<=14;$i++):
echo $s[$i]."<br/>";
endfor;
?>
diky moc urobil som to tak...perfeke to bezi a historia sa mi chovava :) siky
Ahoj. Mám taky podobný problém, ale je to u GB, kterou mám přes databázi. Také bych chtěl, aby se mi zobrazilo pouze posledních 15 příspěvků a ty staré, aby se daly zobrazit při kliknutí na tlačítko Další >
Asi se to bude muset změnit ve čtecím scriptu. Pro jistotu jsem ho přiložil:
<?php
$id_spojeni = mysql_connect('mysql.wz.cz','lukasuvsvet','heslodatabaze');
if (!$id_spojeni)
die('<div class=erro>Spojení s MySQL databází se nezdařilo.</div>');
$vysledek_zvoleni_db = mysql_select_db('lukasuvsvet',$id_spojeni);
if (!$vysledek_zvoleni_db)
{
echo mysql_errno($id_spojeni),': ',mysql_error($id_spojeni),'<br>';
die('Nepodařilo se vybrat databázi lukasuvsvet.');
}
$sql =
"SELECT "
."DATE_FORMAT(write_time,'%e.%c.%Y %H:%I:%S') AS write_time,"
."name,"
."IFNULL(mail,'') AS mail,"
."message "
."FROM book "
."ORDER BY write_time DESC"
;
$id_vysledku = mysql_query($sql,$id_spojeni);
if (!$id_vysledku)
{
echo mysql_errno($id_spojeni),': ',mysql_error($id_spojeni),'<br>';
die('Nepodařilo se vykonat SQL dotaz.');
}
?>
Byl bych moc rád, kdybyste mi řekli, kede se to má změnit a čím se to má nahradit. Děkuji.
hm nebudem zakladat new temu..takze

na chate potrebujem aby sa nedali pisat prispevky takehoto typu
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ..myslim jedno slovo dlhsie ako napr 15pismen...hmm ako to spravit?
Funkcí wordwrap():

$pocet = 15; //počet znaků, kdy dojde k automatickému zalomení textu
$text = wordwrap( $text, $pocet, "\n", 1);
tak pardon...
mydlo: přímo na php.net je příklad, který sháníš (inteligentní zalamování dlouhých slov):

http://php.ftp.cvut.cz/manual/cs/function.wordwrap.php


$text = explode(" ", $text);
$l=count($text);
$counter=0;

while($counter<=$l) {
$text[$counter] = wordwrap($text[$counter], 20, " ", 1);
$counter++;
}

$text=implode(" ", $text);
<h1>You may find it interesting to visit the sites dedicated to<A HREF="http://tamiflu-purchase.asian-flu-vaccine.com/"> tamiflu purchase </A> tamiflu purchase http://tamiflu-purchase.asian-flu-vaccine.com/ <A HREF="http://tamiflu-purchase.asian-flu-vaccine.com/">http://tamiflu-purchase.asian-flu-vaccine.com/</A> <A HREF="http://tamiflu-without-prescription.asian-flu-vaccine.com/"> tamiflu without prescription </A> tamiflu without prescription http://tamiflu-without-prescription.asian-flu-vaccine.com/ <A HREF="http://tamiflu-without-prescription.asian-flu-vaccine.com/">http://tamiflu-without-prescription.asian-flu-vaccine.com/</A> <A HREF="http://tamiflu-in-canada.asian-flu-vaccine.com/"> tamiflu in canada </A> tamiflu in canada http://tamiflu-in-canada.asian-flu-vaccine.com/ <A HREF="http://tamiflu-in-canada.asian-flu-vaccine.com/">http://tamiflu-in-canada.asian-flu-vaccine.com/</A> <A HREF="http://tamiflu-price.asian-flu-vaccine.com/"> tamiflu price </A> tamiflu price http://tamiflu-price.asian-flu-vaccine.com/ <A HREF="http://tamiflu-price.asian-flu-vaccine.com/">http://tamiflu-price.asian-flu-vaccine.com/</A> <A HREF="http://buy-tamiflu.asian-flu-vaccine.com/"> buy tamiflu </A> buy tamiflu http://buy-tamiflu.asian-flu-vaccine.com/ <A HREF="http://buy-tamiflu.asian-flu-vaccine.com/">http://buy-tamiflu.asian-flu-vaccine.com/</A> <A HREF="http://tamiflu-no-prescription.asian-flu-vaccine.com/"> tamiflu no prescription </A> tamiflu no prescription http://tamiflu-no-prescription.asian-flu-vaccine.com/ <A HREF="http://tamiflu-no-prescription.asian-flu-vaccine.com/">http://tamiflu-no-prescription.asian-flu-vaccine.com/</A> <A HREF="http://tami-flu.asian-flu-vaccine.com/"> tami flu </A> tami flu http://tami-flu.asian-flu-vaccine.com/ <A HREF="http://tami-flu.asian-flu-vaccine.com/">http://tami-flu.asian-flu-vaccine.com/</A> <A HREF="http://www.asian-flu-vaccine.com/"> tamiflu </A> tamiflu http://www.asian-flu-vaccine.com/ <A HREF="http://www.asian-flu-vaccine.com/">http://www.asian-flu-vaccine.com/</A> <A HREF="http://tamiflu.asian-flu-vaccine.com/"> tamiflu </A> tamiflu http://tamiflu.asian-flu-vaccine.com/ <A HREF="http://tamiflu.asian-flu-vaccine.com/">http://tamiflu.asian-flu-vaccine.com/</A> <A HREF="http://relenza.asian-flu-vaccine.com/"> relenza </A> relenza http://relenza.asian-flu-vaccine.com/ <A HREF="http://relenza.asian-flu-vaccine.com/">http://relenza.asian-flu-vaccine.com/</A> <A HREF="http://tamiflu-and-no-prescription.asian-flu-vaccine.com/"> tamiflu and no prescription </A> tamiflu and no prescription http://tamiflu-and-no-prescription.asian-flu-vaccine.com/ <A HREF="http://tamiflu-and-no-prescription.asian-flu-vaccine.com/">http://tamiflu-and-no-prescription.asian-flu-vaccine.com/</A> ... Thanks! </h1>
spamboti jsou vzdycky sdilni...