/    Sign up×
Community /Pin to ProfileBookmark

Select "ALL" in a Query

Hi. Hopefully an easy question for you all.

I have a page that queries a database, and am trying to build a filter for it. The SQL query is something like

[B]SELECT * FROM Users WHERE Website = [I]value[/I][/B] (where [I]value[/I] is provided in the URL). This has been working great, until i want to return ALL results, regardless of the value of Website. In other words, run the query [B]SELECT * FROM Users[/B]

Normally i would use a this different query, but this is embedded deep within a content management system, and cannot be modified easily.

I have tried leaving the value of Website blank in the URL but this returns no results.

Is there some way of modifying the URL so all results are returned, without changing the SQL query?

Thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@tripwaterMay 25.2004 — I am not really sure what you are trying to do. I think I get the overall task at hand but confused still.


If you want your query to change contingent upon some sort of selection or option on the previous page, again this may not be what you are asking...



$query = "select * from users ";


if (URL)

$query .= " where Website = value";

$result = @mysql_query($query);


again I am not sure what you are working with but if all you need is these 2 options why not append the where clause if your condition is met?

Hope this helps
×

Success!

Help @Rik_Comery spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...