Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Replying to PHP Script: Separating News Into Pages


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

Posted 26 March 2006 - 10:08 PM

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

Hercco

Posted 26 March 2006 - 04:09 PM

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


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.:lol:

CrazyPensil

Posted 24 March 2006 - 03:43 PM

look. I' ve got such a script to add news:

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:

<?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\">&nbsp;$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:

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;
}

Review the complete topic (launches new window)