开发者

Dynamic query with varying variables?

Sorry if the title seems misleading, I wasn't sure of the best way to put it.

I have a 2 column table, in the table there's a list of USER_ID's and INTEREST's.

On my page I have a query which calls all interests and puts them into a jq开发者_如何学运维uery marquee.

I would like to make each value link to a page that then runs a query and displays all USER_ID's with the same INTEREST.

In my head the only way (I know how) is to have a list of IF statements that contain queries, so

if($value = 'soccer'){run query that gets all users with soccer as interest}
elseif($value = 'tennis'){run query that gets all users with tennis as interest}
and so on...

as the values wont be set its impossible for me to write this page, Whats the best way to build this?

Im still a brginner with PHP so any helps greatly appreciated! Thanks


why not just use:

select users with interest = $value

Unless I'm really misreading your question.

If you're looking for the mysql syntax to pull everything from a table users with a certain interest

"SELECT * FROM `users` WHERE interest = $value";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜