Hi brothers ,
I have a file archive.php that contains the last posts and it shows the title of the subjects but I wanna also show the part of the subject description I mean part of the text in archive.php , Assume that is archive.php :
Betterphp
Betterphp is a free php tutorial provider ...
________________________
Youtube
Hi, in this post I introduce you with youtube ...
pages : 1 2
I want to show short description that is fetched from the database with what mysql function can I do it ?
I hope you understand ,
Thanks in advance
Showing Part Of The Content For Description By Mysql
Re: Showing Part Of The Content For Description By Mysql
In the query, use the JOIN function. It works the same as the php substr function; first parameter is the field, second is the amount of characters you want.
Re: Showing Part Of The Content For Description By Mysql
Can you show me an example ?
Thanks
Thanks
Re: Showing Part Of The Content For Description By Mysql
I meant to say left… not join.
SELECT `title`, `date`, LEFT(`description`, 30) FROM `posts` WHERE `post_id` = {$id}
Re: Showing Part Of The Content For Description By Mysql
You can also do
SELECT `title`, `date`, SUBSTRING_INDEX(`description`, ' ', 30) FROM `posts` WHERE `post_id` = {$id}which would give you the first 30 whole words. It just looks a little nicer I think