User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,029 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,851 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 616 | Replies: 14 | Solved
Reply
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Displaying a limited number of words from MySQL

  #11  
Jun 30th, 2008
Ah!!! You can do it this way.
  1. $query = "SELECT SUBSTRING_INDEX(tip,' ',8) as tip FROM tips";
This will solve your problem, I am sure.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: May 2008
Posts: 49
Reputation: antwan1986 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
antwan1986's Avatar
antwan1986 antwan1986 is offline Offline
Light Poster

Re: Displaying a limited number of words from MySQL

  #12  
Jun 30th, 2008
Originally Posted by nav33n View Post
Ah!!! You can do it this way.
  1. $query = "SELECT SUBSTRING_INDEX(tip,' ',8) as tip FROM tips";
This will solve your problem, I am sure.


Thank you very much, it seems to work now! So the problem was that it was not assigning the SUBSTRING_INDEX result to a variable?

Anthony
"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Displaying a limited number of words from MySQL

  #13  
Jun 30th, 2008
No.. You are creating an alias for SUBSTRING_INDEX(tip, ' ',8) . Php parser will look for a column name and since you aren't specifying any, it will be empty.
SUBSTRING_INDEX(tip, ' ',8) as tip
This will return the result under "user defined" column name tip, so that php parser can access it.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: May 2008
Posts: 49
Reputation: antwan1986 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
antwan1986's Avatar
antwan1986 antwan1986 is offline Offline
Light Poster

Re: Displaying a limited number of words from MySQL

  #14  
Jun 30th, 2008
Thanks again for explaining that; you have (as always) been a great help. Much appreciated friend!
"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 239
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Displaying a limited number of words from MySQL

  #15  
Jun 30th, 2008
You are welcome !
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:46 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC