Connecting Tech Pros Worldwide Help | Site Map

Search within a search within a search

  #1  
Old January 25th, 2006, 07:05 PM
Rachelle
Guest
 
Posts: n/a
I'm having some trouble with the search field that i am setting up
using PHP and HTML, I am connecting to a database to return proper
information pertaining to something being searched. I originally set
up a search to work like this :

$SQL = "
select id,
name
from repository
where upper(name) like upper('%$search%')
";
$Result=SubmitQuery($db,$SQL);
while (OCIFetch($Result)) {
$repo_id = OCIResult($Result,"ID");
$name = OCIResult($Result,"NAME");
echo"

and display the results accordingly, This was one teer of the
searching, the database would then search modules and files just as
seen above, but I ran into the problem where the correct values are not
being passed, so it was searching all repositories, then all modules,
then all files.... is it possible to search like this:

Repository #1
---Module #1 in Repo#1
------files in Module #1
---Module #2 in Repo #1
------files in Module #2 Repo #1
etc.\
\\
\\
\\
Repository #2
--Module #1 in Repo #2
etc......

is this possible to do a search under a search under a search with SQL
PHP?????

  #2  
Old January 25th, 2006, 11:25 PM
Pedro Graca
Guest
 
Posts: n/a

re: Search within a search within a search


Rachelle wrote:
<snip>[color=blue]
> is it possible to search like this:
>
> Repository #1
> ---Module #1 in Repo#1
> ------files in Module #1
> ---Module #2 in Repo #1
> ------files in Module #2 Repo #1
> etc.\
> \\
> \\
> \\
> Repository #2
> --Module #1 in Repo #2
> etc......
>
> is this possible to do a search under a search under a search with SQL
> PHP?????[/color]

SELECT not tested:

select <fields>
from repository r
join module m on r.rep_id = m.rep_id
join file f on m.mod_id = f.mod_id
where <conditions>
order by <whatever>
limit <something>

With this you'll get something like

rep_id | rep_name | mod_id | mod_name | file_id | file_name | ...
-------+----------+--------+----------+---------+-----------+----
1 | master | 1 | test | 1 | test.php | ...
1 | master | 1 | test | 2 | echo.php | ...
1 | master | 2 | environ | 3 | data.php | ...
2 | slave | 3 | listen | 4 | open.php | ...
....



Then use PHP to format the data however you like best :-)
Maybe putting it all in an array first will make it easier to format as
you need.

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search within results in c#.net sagard answers 0 February 21st, 2007 03:41 PM
Search within the website Manoj Paramu Das answers 0 November 22nd, 2005 11:07 AM
Search within a site Manoj Paramu Das answers 2 November 18th, 2005 10:45 AM
Search within the website Manoj Paramu Das answers 0 July 21st, 2005 03:21 PM
Search within a variable JF Potvin answers 0 July 19th, 2005 05:36 AM