PDA

View Full Version : Only displaying so many characters of a result(php mysql)...


sir pannels
08-14-2004, 12:59 AM
Hey..

have qry and list - bring back the last 10 titles in a DB and display the within the list/while... I need to only show .. say .. 25 characters of the title tho.. Ive tried substr stuff but as its inside a while and also inside a list ive got nowhere. There any query shortcuts?

Cheers:)
Sir P

raf
08-14-2004, 09:26 AM
you can use a left(variablename,25)

as in


select var1, left(title,25) as titlestart from table

sir pannels
08-14-2004, 09:46 AM
Hey raf!

Cheers :) works good - however I need two variables from that table.. how do I get the second? ive tried putting AND within the query but I get an error. The second var does not need to be cut up or anything.

Do I need to run an entirly new statement?

Cheers
P

raf
08-14-2004, 10:17 AM
not sure i understand.

the query i posted will return 2 'variables' ==> the value inside column with title var1 and the 25 first letters of the value in columns with title 'title'

sir pannels
08-14-2004, 10:31 AM
My bad raf - i misread.. works great :)

Cheers
Sir P