Jump to content

How to take a result like this ?


Rommeo

Recommended Posts

For example you are searching for the username "userPHP"

I want a result like :

 

user1

user335

userAllyss

userPHP | male | 26 years old | likes computers and sea

userRed

userMad

userZero

 

 

What I really want is; I want to print the data in the middle, not at the first or last.

Is there a keyword for this for mySQL ?

 

( I have a users table

username | gender | age | hobbies )

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/233871-how-to-take-a-result-like-this/
Share on other sites

I want to print the "search-word" in the middle of all words,

 

if I do : select * from users where user  = %userphp% order by username ASC

 

it will give me the result like

userphp

userxyz

userzero..

 

but I want it like

userabc

userpepe

userphp

userxyz

userzero

 

so if the user was actually trying to find userpepe, he/she needs just to click "userpepe", that s what I m trying to do.

 

( notice that 2 usernames before the "search-word" and two usernames after "search-word" in the result I m trying to get )

 

I don't follow -- are you saying that mysql is giving you the correct results, but you just want to format to output differently?

Exacty, I just mean that, how can I take the results that are before the correct result and print them ? I need two queries ? or is there a keyword/function for to do that ?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.