Solved

Search function not working

Posted on 2016-10-05
14
61 Views
Last Modified: 2016-10-21
The search function on the following page isn't working properly: http://www.ssuexed.com/search.php?year=2017&sem=0&ge=C3%2C+*ETH&id=0&cName=&cDept=&tLastName=

For example, if you select the option for GE Type as "C3, *ETH", you will obtain an output that includes "GE C3" as well.

I am attaching the code files - I am thinking that the problem must be in one of these files, i.e., search_subcats.php file, but I am not certain.

I would appreciate any help.
search.php
search_cache.php
search_subcats.php
0
Comment
Question by:geeta_m9
  • 6
  • 6
14 Comments
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41831415
Where is the function showSearchTable defined (line 218 of search.php)

$catalog->showSearchTable($ge, $cName, $cDept, $tLastName);

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41831460
also, where is _cleanVar() function defined? does it include urldecode function
0
 

Author Comment

by:geeta_m9
ID: 41832139
I don't know. I am sending you the rest of the files that I have.
course.php
programs.php
catalog.php
_catalog_defines.php
test.php
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41832216
Nope does not appear to be in any of those.
0
 

Author Comment

by:geeta_m9
ID: 41832250
Ok, I managed to find some more php files which were in an "includes" folder
_catalog_defines-1.php
_stdfunctions.php
0
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41832330
Not there either.
0
 

Author Comment

by:geeta_m9
ID: 41832379
0
 

Author Comment

by:geeta_m9
ID: 41832436
I believe the function you are looking for is in catalog_container-1.php
0
 
LVL 56

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41832741
Bingo
This function produces two possible queries
If there is a tLastName
SELECT DISTINCT 
	c.id,
	s.dept,
	s.dept_code,
	c.course_title,
	c.active,
	s.year,
	s.sem,
	c.ge,
	c.course_type 
FROM
	courses AS c,
	sections AS s,
	teachers as t,
	tea_sec_rel as tsr 
WHERE 
	s.course_id_rel=c.id AND 
	s.year=2016 AND 
	s.sem=1 AND (
		c.active=1 OR 
		c.active=3 OR 
		c.active=4 OR 
		c.active=7) AND 
	course_title LIKE '%Name%' AND 
	s.dept='LAST' AND 
	s.dept_code='Dept' AND 
	c.ge LIKE 'C3, *ETH' AND 
	t.lname LIKE '%Smith%' AND 
	tsr.teacher_id=t.id AND 
	tsr.section_id=s.id 
ORDER BY 
	s.dept,
	s.dept_code

Open in new window

If there is not a tLastName
SELECT DISTINCT 
	c.id,
	s.dept,
	s.dept_code,
	c.course_title,
	c.active,
	s.year,
	s.sem,
	c.ge,
	c.course_type 
FROM 
	courses AS c, 
	sections AS s 
WHERE 
	s.course_id_rel=c.id AND 
	s.year=2016 AND 
	s.sem=1 AND (
		c.active=1 OR 
		c.active=3 OR 
		c.active=4 OR 
		c.active=7) AND 
	course_title LIKE '%Name%' AND 
	s.dept='LAST' AND 
	s.dept_code='Dept' AND 
	c.ge LIKE 'C3, *ETH' 
ORDER BY 
	s.dept,
	s.dept_code

Open in new window

Both queries appear to be incapable of producing results with GE C3 - which means we probably need to see the data.
If you can confirm the query by adding the following to the catalog_container-1.php
...
		if ($tLastName) { // or s.year LIKE ('$curYr'+1) // AND s.sem=$this->sem
			$couTea = "AND t.lname LIKE '%$tLastName%' AND tsr.teacher_id=t.id AND tsr.section_id=s.id";
// ADD THIS			
echo "
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s, teachers as t, tea_sec_rel as tsr
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe $couTea
							ORDER BY s.dept,s.dept_code";

			$iRes = _SQLQuery("
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s, teachers as t, tea_sec_rel as tsr
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe $couTea
							ORDER BY s.dept,s.dept_code");
		}
		else {
// AND THIS			
echo "
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe
							ORDER BY s.dept,s.dept_code";
			$iRes = _SQLQuery("
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe
							ORDER BY s.dept,s.dept_code");
		}    
...

Open in new window

And then post the query that is dumped from that.
0
 

Author Comment

by:geeta_m9
ID: 41833994
Hi Julian,

I do not have a test server to add the code to the catalog_container-1 program file and run it. If I insert it into the program and upload it, it will be live.

I can, however, run SQL queries against the database and obtain the output. So, if you could give it to me in that format, that would be great.
0
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41834004
I don't have anything to give you - I want to see what queries the code produces.
0
 

Author Comment

by:geeta_m9
ID: 41854317
Sorry, I forgot to close this question. The problem has been resolved.

Thank you for your help.

Geeta
0
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41854639
You are welcome.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question