General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 11th, 2003, 04:09 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 6
Pulling Limited Characters

I am trying to pull limited characters of contents stored in the DB.

this pulls the title and the full contents.
PHP Code:
 $query "SELECT id, title, content, date FROM article ORDER BY date DESC LIMIT 0, 20"


this pulls the title and no contents.
PHP Code:
 $query "SELECT id, title, left(content,30), date FROM article ORDER BY date DESC LIMIT 0, 20"


I have tried so many ways and I can't seem to nail it.
I would like to only pull around 30 characters of contents...

I hope someone can help, thanks

Reply With Quote
  #2  
Old March 11th, 2003, 09:40 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Zig,
Try this:

PHP Code:
 $query "SELECT id, title, left(content,30) as myContent, date FROM article ORDER BY date DESC LIMIT 0, 20"

Then reference the myContent field instead of the content field.

Reply With Quote
  #3  
Old March 11th, 2003, 11:31 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 6
Talking

Very cool, that did work.. and so simple,
I tried everything I could think of to get that to work. but that =)

Thanks again so much.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Pulling Limited Characters


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway