Forums

This topic is locked

search and results problem

Posted 24 Sep 2002 03:41:23
1
has voted
24 Sep 2002 03:41:23 Andrew Ross posted:
Hi,

I am creating search and result pages with UltraDev, Phakt and MySQL. When I test my SQL statement in Databinding>Recordset everything works fine with my four search fields: Category, Province, Nearest Major City, Exact Location. But when I try and enter the search terms into the actual search page nothing seems to work on the results page. It comes up completely blank.

I have checked the obvious stuff. My SearchForm Action is set to results.php, the Method is Get and here is an example to the URL after the form is submitted:

www.canphoto.net/canphotodirect/results.php?mnuCategory=5&mnuProvince=%25&mnuNearMajorCity=%25&txtCity=&Submit=Submit

I don't want to post the whole file here, but here is my SQL statement if it helps. If you have any suggestions please let me know. Thanks.

SELECT Categories.Category, Contacts.First_Name, Contacts.Last_Name, Contacts.Company, Contacts.Address_1, Contacts.Address_2, Contacts.City, Provinces.Province, Contacts.Postcode, Contacts.Fax, Contacts.Phone, Contacts.Email_Address, Contacts.WebSite, Contacts.Notes, Contacts.Notes2, Contacts.Notes3, Contacts.Image2, Contacts.Image3, Contacts.Detail, Contacts.Photo
FROM ContactCategories, Contacts, Categories, Provinces, NearMajorCity
WHERE ContactCategories.Category_ID in (varCategory) AND Contacts.Province_ID LIKE 'varProvince' AND Contacts.NearMajorCity_ID LIKE 'varNearMajorCity' AND City LIKE 'varCity%' AND ContactCategories.Contact_ID = Contacts.Contact_ID AND ContactCategories.Category_ID = Categories.Category_ID AND Provinces.Province_ID = Contacts.Province_ID AND NearMajorCity.NearMajorCity_ID = Contacts.NearMajorCity_ID
ORDER BY Category, Last_Name, Company


Replies

Replied 24 Sep 2002 17:27:25
24 Sep 2002 17:27:25 Stuart Harland replied:
ContactCategories.Category_ID in (varCategory)
..Contacts.Province_ID LIKE 'varProvince' AND Contacts.NearMajorCity_ID LIKE 'varNearMajorCity'...

If the elements in your SQL Statement 'varCategory', 'varProvince' and 'varNearMajorCity' are variables populated through the use of 'request.form' or something simlar in PHP...
Then you'll need to alter your statement to accept variables properly in this format:

eg.1
-------
..ContactCategories.Category_ID in (" & varCategory & "...etc
..Contacts.Province_ID LIKE '" & varProvince & "' AND Contacts.NearMajorCity_ID LIKE '" & varNearMajorCity & "'...etc

When passing variables into a SQL statment they need to be seperated from the SQL String:

eg.2
-------
Dim sName
sName = "Ferox"
sSQLstring = "Select * FROM tblNames WHERE name='" & sName & "'"

********************
wheatNOTmeat

Reply to this topic