Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

News Pages

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

News Pages

Postby AaaDee » Fri Jul 19, 2002 2:42 am

Hi, i have got a news page which displays all the News in the database.

But i only want to limit the stories on this page to 90 characteristics. There is then a link on the story which views all of the story on the page.

Any help.

Cheers

Adam
User avatar
AaaDee
New php-forum User
New php-forum User
 
Posts: 25
Joined: Mon Jun 24, 2002 1:10 am
Location: Huddersfield

Re: News Pages

Postby WiZARD » Fri Jul 19, 2002 4:28 am

AaaDee wrote:Hi, i have got a news page which displays all the News in the database.

But i only want to limit the stories on this page to 90 characteristics. There is then a link on the story which views all of the story on the page.

Any help.

Cheers

Adam

RTFM about strlen.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby AaaDee » Fri Jul 19, 2002 4:29 am

what does that mean?
User avatar
AaaDee
New php-forum User
New php-forum User
 
Posts: 25
Joined: Mon Jun 24, 2002 1:10 am
Location: Huddersfield

Postby WiZARD » Fri Jul 19, 2002 5:03 am

AaaDee wrote:what does that mean?

Read
The
F..ing
Manual

about strlen
And one more question how old are you? and how long time you learn PHP?
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby AaaDee » Fri Jul 19, 2002 5:06 am

18, few month.

whats ur problem?

what the hells a php forum for if i cant write my questions down!

:!:
User avatar
AaaDee
New php-forum User
New php-forum User
 
Posts: 25
Joined: Mon Jun 24, 2002 1:10 am
Location: Huddersfield

Postby AaaDee » Fri Jul 19, 2002 6:16 am

hello moody moderator

looked it up, found a way but doesnt work.

i enter

substr($news,0,90); where the code will be displayed and all it displays is


substr(the actual news statement from my database.,0 , 90);

any help, or SORRY for troubling you.
User avatar
AaaDee
New php-forum User
New php-forum User
 
Posts: 25
Joined: Mon Jun 24, 2002 1:10 am
Location: Huddersfield

Postby Oleg Butuzov » Fri Jul 19, 2002 7:59 am

2AaaDee & Wizard
Ani conflicts in at the my teritory!

Way 2.

$string=explode("", $news);

for ($d=0; $d < "90"; $d++)
{
echo $sting[$d];
}


ond one wore... Adam, you are very new in PHP, so please read this thread and (may be) you will be programing more better...
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Jay » Fri Aug 02, 2002 11:53 am

AaaDee wrote:hello moody moderator

looked it up, found a way but doesnt work.

i enter

substr($news,0,90); where the code will be displayed and all it displays is


substr(the actual news statement from my database.,0 , 90);

any help, or SORRY for troubling you.

It sounds to me like you're not using the function correctly. Have you surround them in quote tags? If you have PHP won't see the function as a function, it'll just see it as normal text.

For example:
Code: Select all
<?
print "This story: substr($news,0,90);";
?>


This is wrong because PHP is interpreting the substr as a string, and not a function. The correct procedure is:
Code: Select all
<?
print "This story: ".substr($news,0,90);
?>


Now the function is being processed by PHP instead of being interpretted as a string in itself. This should hopefully fix your problem.

:D
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.