|
|
|
|
![]() ![]() |
Mar 24 2006, 03:43 PM
Post
#1
|
|
|
Member [ Level 1 ] Group: Members Posts: 42 Joined: 17-March 06 From: Russia, St.Petersburg Member No.: 12,058 |
look. I' ve got such a script to add news:
CODE if($mess&&$subj) { $fp=fopen("news.txt", "a"); $d=date("d").".".date("m").".".date("Y"); $c=0; if(file_exists("news.txt")&&filesize("news.txt")>0) { if($c==0) { $news="<nnn>|$subj|$d|$login|$mess\n"; } else { $news="<nnn>|$subj|$d|$login|$mess"; } } else { if($c==0) { $news="|$subj|$d|$login|$mess\n"; } else { $news="|$subj|$d|$login|$mess"; } } fwrite($fp,$news); fclose($fp); $m="Новость успешно добавлена!"; } elseif(!$mess&&$subj) { $m="How about subject?"; } elseif(!$subj&&$mess) { $m="How abot message?"; } else { $m="Complete the following forms:"; } such a one for viewing it: CODE <?php if(file_exists("news.txt")&&filesize("news.txt")!=0) { $fp=fopen("news.txt", "r"); $newss=""; while (!feof($fp)) { $line = fgets($fp, 4096); $newss.=$line; } fclose($fp); $news=explode("<nnn>", $newss); $i=0; $br=""; foreach ($news as $n) { $p=explode("|", $n); if($i>0) { $br="<br>"; } print "$br<div class=\"news\">\n<div class=\"newtitle\"> $p[1]($p[2]), <font class=\"part\">By $p[3]</div></font>\n<div class=\"newbody\"><pre>$p[4]</pre></div></div>"; $c+=4; $i++; } } else { print "<center><div class=\"nonews\">Новостей нет!</div></center>"; $c++; } ?> how should I upgrade it in such a way that my newbody doesn't resize. I mean I wana let there be only n chars on each page. Please, help me with this one!!! P.S. my style file: CODE A:link {
COLOR: #222222; FONT-FAMILY: Verdana; TEXT-DECORATION: none; } A:active { COLOR: #222222; FONT-FAMILY: Verdana; TEXT-DECORATION: none; } A:visited { COLOR: #222222; FONT-FAMILY: Verdana; TEXT-DECORATION: none; } A:hover { color: #ffee00; FONT-FAMILY: Verdana; TEXT-DECORATION: none; } hr { height: 1px; } body { scrollbar-face-color : #4444ff; scrollbar-shadow-color : #4444ff; scrollbar-highlight-color : #4444ff; scrollbar-3dlight-color : #4444ff; scrollbar-darkshadow-color : #4444ff; scrollbar-track-color : #4444ff; scrollbar-arrow-color : #ffee00; font-family: verdana; color: #ffffff; margin-left: 30px; margin-right: 30px; margin-top: 1px; background-color: #808080; } .gb { margin-left: 100px; margin-right: 10px; } div.refuse { color: red; font-weight: bold; } div.nonews { font-family: verdana; margin-left: 3px; margin-right: 3px; background-color: #256E87; border: solid white 1px; } div.mess { margin-top: 3px; margin-bottom: 3px; border: solid white 1px; } div.news { margin-left: 3px; margin-top: 3px; margin-right: 3px; margin-bottom: 3px; border: solid white 1px; } div.newtitle { font-family: verdana; background-color: #256E87; border-bottom: solid white 1px; padding: 2px 3px 1px 4px; } div.newbody { font-family: verdana; font-size: 10pt; top: 27px; margin-left: 15px; padding: 2px; overflow: auto; background-color #000000; } .part { color: #faa664; font-weight: bold; } Table { border: solid white 0px; } tr { border: solid #B9E6F6 1px; } td { border: solid #B9E6F6 1px; } td.h { border: solid #B9E6F6 1px; color: #1D3A46; } input { border: solid #B9E6F6 1px; background-color: white; } |
|
|
|
Mar 26 2006, 04:09 PM
Post
#2
|
|
|
Super Member Group: Members Posts: 595 Joined: 4-September 04 Member No.: 228 |
I had just quick glance through your code so I hope I didn't miss anything. I understood your question is how you can limit the printing of content of the variable $p[4] (or an array element....) to certain length? The answer is bloody easy use function substr
CODE substr($p[4], 0, n); Where n is the number of characters you want to print. And it seems your newsfile contains a news item per line. Right? Just make another script for showing a complete news item and pass the correct line number as parameter to it. Then in this new script read this line and show the news. You might wish to do a length checking in the original news file if a link to this full news item should be displayed. So if the news content is shorter than n the link ("more" for example) wouldn't be displayed. I hope this was what you were after. And have fun coding. |
|
|
|
Mar 26 2006, 10:08 PM
Post
#3
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Validating Posts: 111 Joined: 28-January 06 Member No.: 10,917 |
QUOTE how should I upgrade it in such a way that my newbody doesn't resize. Although I have not tested your code, but I think, due to unwanted resize, your layout is getting distorted. If that be the case, try to use <TABLE> and put all the outputs in <TD> $field_name </TD> tag. I appreciate that the suggestion I have placed here is a mere hint, and not the actual script, obviously based on the assumption that you are facing a layout related problem. Regards, Sid |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 29th August 2008 - 03:28 AM |