RE: [PHP] text problem.
Either use LEFT() in your query, or substr() on the text after it's pulled out to limit it's length. There was a huge discussion on this on the Devshed.com forums on how to do this to break on a word, before or after X characters, etc... It's on the PHP forum, maybe you can find it if you search. ---John Holmes... > -Original Message- > From: r [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 2:45 AM > To: [EMAIL PROTECTED] > Subject: [PHP] text problem. > > Greetings all, > Special greetings to all my new PHP list pals, you know who you are. > > Sorry to be so mysterious in the subject line but i dont know how to > explain > this in one line. > > ever visit a site and you get this text (Or something like this...heheh) > > "This morning shockingly Bill Gates claims he is broke! > The kooky billionaire is...(link)subscribe / login to read this > fully." > > "This morning shockingly Bill Gates claims he is GAY! > The kooky billionaire is...(link)subscribe / login to read this > fully." > > "This morning shockingly Bill Gates claims he is impotent! > The kooky billionaire is...(link)subscribe / login to read this > fully." > > etc etc > > > Basically, its querying the database and instead of displaying the whole > results it just taking the first 2 lines or X number of characters and > then > adding the link stuff.any idea how to do this? > > NOTE:Before i get you microsoft lovers coming after my throat...I > HAVE > NOTHING AGAIN BILL GATES/MICROSOFT. > I actually use a lot of his companys software...am running win2k myself. > Get off my back. > > And for the rest of you who think that i am suffering from insanityyou > are wrong...I am enjoying every minute of it! > heheheh ahhahahah ahahhah GAGAGAGAG HAHAHA HEHEH > > ANY help appreciated. > Cheers, > -Ryan > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] text problem.
If you want to do it on a # of char's (the easiest), check out substr() in the manual. Otherwise, to break on a full word, this will do the job: Do your query as per usual, the below assumes your text thing is $fulltext. I put strip_tags() in there, because if you have a tag it will: a) screw up the word count ( contains 3 spaces) b) screw up the page if foo bah gets trimmed to foo... the rest of the page will be bold Like I said, substr() is a helluva lot easier, but could break mid-word. Justin French Creative Director http://Indent.com.au on 29/04/02 7:44 PM, r ([EMAIL PROTECTED]) wrote: > Greetings all, > Special greetings to all my new PHP list pals, you know who you are. > > Sorry to be so mysterious in the subject line but i dont know how to explain > this in one line. > > ever visit a site and you get this text (Or something like this...heheh) > > "This morning shockingly Bill Gates claims he is broke! > The kooky billionaire is...(link)subscribe / login to read this fully." > > "This morning shockingly Bill Gates claims he is GAY! > The kooky billionaire is...(link)subscribe / login to read this fully." > > "This morning shockingly Bill Gates claims he is impotent! > The kooky billionaire is...(link)subscribe / login to read this fully." > > etc etc > > > Basically, its querying the database and instead of displaying the whole > results it just taking the first 2 lines or X number of characters and then > adding the link stuff.any idea how to do this? > > NOTE:Before i get you microsoft lovers coming after my throat...I HAVE > NOTHING AGAIN BILL GATES/MICROSOFT. > I actually use a lot of his companys software...am running win2k myself. > Get off my back. > > And for the rest of you who think that i am suffering from insanityyou > are wrong...I am enjoying every minute of it! > heheheh ahhahahah ahahhah GAGAGAGAG HAHAHA HEHEH > > ANY help appreciated. > Cheers, > -Ryan > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] text problem.
On Monday 29 April 2002 17:44, r wrote: > Greetings all, > Special greetings to all my new PHP list pals, you know who you are. > > Sorry to be so mysterious in the subject line but i dont know how to > explain this in one line. > > ever visit a site and you get this text (Or something like this...heheh) > > "This morning shockingly Bill Gates claims he is broke! > The kooky billionaire is...(link)subscribe / login to read this fully." > Basically, its querying the database and instead of displaying the whole > results it just taking the first 2 lines or X number of characters and then > adding the link stuff.any idea how to do this? You yourself have already outlined how to do it: get text from db get the first 100 chars from the text drop the last 'word' (it may be incomplete), using explode(), array_pop() You may have to refine the process to suit your needs. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* The discerning person is always at a disadvantage. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] text problem.
Greetings all, Special greetings to all my new PHP list pals, you know who you are. Sorry to be so mysterious in the subject line but i dont know how to explain this in one line. ever visit a site and you get this text (Or something like this...heheh) "This morning shockingly Bill Gates claims he is broke! The kooky billionaire is...(link)subscribe / login to read this fully." "This morning shockingly Bill Gates claims he is GAY! The kooky billionaire is...(link)subscribe / login to read this fully." "This morning shockingly Bill Gates claims he is impotent! The kooky billionaire is...(link)subscribe / login to read this fully." etc etc Basically, its querying the database and instead of displaying the whole results it just taking the first 2 lines or X number of characters and then adding the link stuff.any idea how to do this? NOTE:Before i get you microsoft lovers coming after my throat...I HAVE NOTHING AGAIN BILL GATES/MICROSOFT. I actually use a lot of his companys software...am running win2k myself. Get off my back. And for the rest of you who think that i am suffering from insanityyou are wrong...I am enjoying every minute of it! heheheh ahhahahah ahahhah GAGAGAGAG HAHAHA HEHEH ANY help appreciated. Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php