I'm trying to figure out if this is possible, and cannot find any information about it.

Specifically what I want to do, for example, is allow a web-based user to search for a particular value in one field the first time around. If that returns an overwhelming number of results, I'd like for them to be able to search from within the results of the first query.

I suppose I could have the prior query statement POSTed with the results and nest a bunch of statements, but this seems like it could get really ugly in a hurry. :eek:

Any ideas?

I believe within MySQL 4.1 it supports subqueries.. if thats what your looking for.

Hmm, no, a subquery is just a one-time thing, too. I'm talking about subsequent calls to the mysql_query() function.

For example, let's say I have a database with tons of records. Here's the first query, which returns thousands of results:

$query="SELECT * FROM sometable WHERE [some condition]";
$result=mysql_query($query);

[at this point, code execution has stopped and the user is on a different page. The user decides to narrow the search, so I'd like to know if there is something akin to the following]

$query2="SELECT * FROM $result where [condition2]";
$result2=mysql_query($query2);

Where $result is a pointer to a table in memory containing the rows that were pulled in the first query.

Mmmm... maybe creating a temporary table with the results of the first query but that will kill performance. In my opinion it is better to create a seach form that "remembers" the values and then the client can always have that reference and change the options to narrow the search.

Member Avatar for edshuck

My site is a community (neighborhood) site and there are all manner of products available at shops. This is my category area.

I do this:

super category >> many to many >> category >> many to many >> shop.

I start with a super category (say dining). Click it and the many to many has dining pointing to Chinese, Italian, Catering and so on. This is displayed. Then the viewer selects the specific category and then the full select statement is put into effect.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.