This topic is locked

Advanced Search Issues

5/14/2008 5:59:36 PM
PHPRunner General questions
L
Lisa2006 author

Hi Forum,
I have 2 tables as follows:
Table: journey

Fields: start_town, end_town, etc...
Table: suppliers

Fields: begin_town, finish_town, etc..
I've set up the journey table, so that you type in your journey details; start_town, end_town, etc. via journey_add.php
When the user clicks submit, a piece of logic at the journey | Add page: After record added Event is excuted. This code simply checks the supplierstable to see if:
start_town = begin_town

and

end_town = finish_town
If this condition is met, i want to be redirected to the suppliers table and show only the occurances of records that match
To Simply the above: imagine i go directly to the suppliers table and click 'Advanced Search'. I enter begin_town and finish_town. Upon clicking the 'Search' button only the matched records are displayed on the suppliers_list.php page.
Not sure how or where to code things. Your help & support would be much appreciated.
Lisa

J
Jane 5/15/2008

Hi,
contruct URL with advanced search result and redirect to this URL.

Here is the "How to get the URL of advanced search results page" article:

http://www.asprunner.com/forums/index.php?showtopic=5704

L
Lisa2006 author 5/15/2008

Hi Jane,
Per the article i've changed the following:
Supplier Table | Visual Editor | advanced search page | HTML Mode
from:

<form method="POST" action="suppliers_list.php" name="editform">
to:

<form method="GET" action="suppliers_list.php" name="editform">
I'm not sure how to contruct the URL.

Here is the code that i have in the journey | Add page: After record added Event
$result = mysql_query("SELECT * FROM suppliers");

while($row = mysql_fetch_array($result))

{

if (code for town check){

header("Location: http://www.mywebsite.com/suppliers.php");

}

}
Further help & support would be greatly appreciated.
Thank you
Lisa

J
Jane 5/15/2008

Hi,
just run advanced search, copy and paste the URL into your code.

L
Lisa2006 author 5/15/2008

Hi Jane,
I have copied the url generated after the search to the add page redirect. It works only for static entries.
I need to be able to pull the contents of journey table | begin_town field into the URL
suppliers_list.php?a=advsearch&type=and&asearchfield%5B%5D=begin_town&asearchopt_begin_town=Equals&display_value_begin_town=halesowen&value_begin_town=halesowen&display_value_begin_town=&value1_begin_town=&asearchfield%5B%5D=begin_city&asearchopt_begin_city=Equals&value_begin_city=&value1_begin_city=&asearchfield%5B%5D=finish_town&asearchopt_finish_town=Contains&value_finish_town=cannock&value1_finish_town=&asearchfield%5B%5D=finish_city&asearchopt_finish_city=Contains&value_finish_city=&value1_finish_city=
I've highlighted the presence of begin_town: halesowen in the URL to demonstrate that this is the static entry on the search page.
Again, more help and support needed.
Many thanks
Lisa

L
Lisa2006 author 5/15/2008

Hi Forum,
I've managed to figure it out.
Here's goes



$result = mysql_query("SELECT * FROM suppliers");

while($row = mysql_fetch_array($result))

{

if (code for town check){

$_SESSION["begin_town"] = $values["start_town"];

$_SESSION["begin_city"] = $values["start_city"];

$_SESSION["finish_town"] = $values["end_town"];

$_SESSION["finish_city"] = $values["end_city"];
header("Location:http://www.mywebsite.com/suppliers_list.php?a=advsearch&type=and&asearchfield%5B%5D=begin_town&asearchopt_begin_town=Equals&value_begin_town=."&value1_finish_town=&asearchfield%5B%5D=finish_city&asearchopt_finish_city=Contains&value_finish_city=&value1_finish_city=";);

}

}
Sorry for any confusion as the final solution now includes the existance of start & end cities.
Hope this helps anyone looking for a similar solution
Lisa

L
Lisa2006 author 5/15/2008

Hi Forum,
I have another question which relates to the solution to date.
Is there any way on the Advanced Search page to create an OR condition.
_Example
Data entered into Supplier Table Advanced Search:

_begin_town = solihull

begin_city = birmingham

finish_town = salford

finish_city = manchester
Lets say we have a record on the supplier table with the following criteria:
begin_town = solihull

begin_city = west midlands

finish_town = salford

finish_city = salford
I would like to show on the list page the above record details, given that the details are not identical. I've had a play with the different search types: contains, equals, etc. but cannot see a way of achieving this. Is there any way of comparing as follows:
if data entered begin_town (solihull) = preset data record begin_town (solihull)



OR

data entered begin_city (birmingham) = preset data record begin_city (west midlands)
Currently, the solution seems to work as an AND condition.
Your help would be much appreciated.
Lisa

J
Jane 5/16/2008

Hi,
to use OR condition just select Any condition option on the Advanced search page.