0
I have a posting system done: the user posts and when the post contains a # followed by a word, the word is automatically added in another column with a comma. Post example:
Good #Personal @Stackoverflow Day, could you help me # ?
Example of record in table:
id: 1, post: Good #Personal @Stackoverflow Day, would you #help me ? , Author: Raphael, hashtags: day,help
Only that I am mounting a page to appear only posts containing hashtag x.
I need a code that shows only the records that contain the word x within the column hashtags
.
Example: I need you to show all the records that contain the good word in the column hashtags
.
id: 1, post: Could you help me #help, by the way, #good day! , Uthor: Raphael, hashtags: help,
id: 2, post: #Good evening @Stackoverflow staff, could you help me ? , Author: Raphael, hashtags: good, night,
id: 3, post: #Nice @Stackoverflow personal #fds, could you #help me ? , Author: Raphael, hashtags: good,fds,help
Then the system will show only the records with id 1 and 3 for containing the good word within the column hashtags
.
Does this code help? $str = '#helloworld #test #video #youtube Bon Iver are the best Daily Surprise :D'; preg_match_all('/#([ s]+)/', $str, $Matches); $hashtags = implode(',', $Matches[1]); var_dump($hashtags);
– mcamara
Could you explain a little more how you want? I could not understand very well, leave examples if possible. See also [Ask]
– Francisco
@miltoncamara It is not to show the words without the # but to show the records that it contains within the column
hashtags
.– Raphael
@Raphael, now understood, do you want to do this query in Mysql? Which bank are you using?
– mcamara