This topic is locked

Lookup List (not based on a table) and advanced search

7/24/2006 6:35:09 PM
PHPRunner General questions
P
phpwalker author

I am using various lookup lists that are not base on a table...
for example one field is called IssueA and the user can choose one of the following from the lookup list:
supporter

leaning toward

undecided

leaning away

opposed
I can sort properly on these fields in list view (NOTE: This is a table view using multiple tables joined in a SQL query)...
Also, when I go into advanced search I see the drop down list correctly after the field IssueA... but when I try to run the advanced search I get a SQL error...
(These lookup lists seem to work fine when I am using a single table list view - for example, I have another table with a lookup list not based on a table for sex: ---> drop down choices are M, F and I can used the advanced search on this field from this single table list view)...
problem seems to be when i am using multiple tables in a list view, the lookup list field causes an error...
see error below:
Technical information

Error type 256

Error description Unknown column 'voters.issueA' in 'where clause'

URL www.xxxxx.com/test/votersANDissues_list.php

Error file /home/xxxxx/public_html/test/include/dbconnection.php

Error line 26

SQL query SELECT `voters`.`LastName`, `voters`.`FirstName`, `voters`.`Phone`, `voters`.`PhoneNotes`, `voters`.`Street`, `voters`.`houseNum`, `voters`.`Party`, `voters`.`group`, `voterIssues`.`issueA`, `voterIssues`.`issueB`, `voterIssues`.`issueC`, `voterIssues`.`issueD`, `voterIssues`.`issueE`, `voterIssues`.`issueF`, `VotingHistory`.`SuperVoter` FROM `voterIssues` RIGHT OUTER JOIN `voters` ON (`voterIssues`.`voterID` = `voters`.`voterID`) RIGHT OUTER JOIN `VotingHistory` ON (`VotingHistory`.`HVoterID` = `voters`.`voterID`) where (1=1 and (`voters`.`issueA`='supporter')) and (`voters`.`group`='EB') ORDER BY `Street` ASC, `houseNum` ASC, `LastName` ASC
sidenote: where is this 1=1 in the where clause coming from???
any help would be greatly appreciated

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=3053&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />

J
Jane 7/25/2006

Hi,
To make your pages working modify function GetFullFieldName in the include/dbcommon.php file.

Take a look at this article to find where and how make this change:

search and sort lookup values

P
phpwalker author 7/25/2006

I am sorry ... I am still confused... the link you suggested is for lookup lists that are based on another table in the database... In my case, the lookup lists are not (they were based on a list of values)...
Should I be entering these lookup values into a table to get this to work?
Karen

J
Jane 7/25/2006

Karen,
I'm sorry i gave you wrong link.

Here is article you need:

http://www.xlinesoft.com/phprunner/docs/us...sql_queries.htm
BTW, your issue is related to JOIN clause, not the Lookup wizard.

P
phpwalker author 7/25/2006

tks

P
phpwalker author 7/25/2006

BTW, your issue is related to JOIN clause, not the Lookup wizard.


Are you sure the problem is with SQL? All sorts work (including on lookup fields) and ALL searches work EXCEPT those that are searching on the Lookup List fields?
Anyway, I tried to make changes as suggested in the article you sent (but once again, that article referred to values in another table NOT a Lookup List based on VALUES that I typed in).
So here is what I tried:
Old Query:
SELECT

`voters`.`LastName`,

`voters`.`FirstName`,

`voters`.`Phone`,

`voters`.`PhoneNotes`,

`voters`.`Street`,

`voters`.`houseNum`,

`voters`.`Party`,

`voters`.`group`,

`voterIssues`.`issueA`,

`voterIssues`.`issueB`,

`voterIssues`.`issueC`,

`voterIssues`.`issueD`,

`voterIssues`.`issueE`,

`voterIssues`.`issueF`,

`VotingHistory`.`SuperVoter`

FROM `voterIssues`

RIGHT OUTER JOIN `voters` ON (`voterIssues`.`voterID` = `voters`.`voterID`)

RIGHT OUTER JOIN `VotingHistory` ON (`VotingHistory`.`HVoterID` = `voters`.`voterID`)
New Query:
SELECT

`voters`.`voterID`,

`voters`.`LastName`,

`voters`.`FirstName`,

`voters`.`Phone`,

`voters`.`PhoneNotes`,

`voters`.`Street`,

`voters`.`houseNum`,

`voters`.`Party`,

`voters`.`group`,

`voterIssues`.`issueA`,

`voterIssues`.`issueB`,

`voterIssues`.`issueC`,

`voterIssues`.`issueD`,

`voterIssues`.`issueE`,

`voterIssues`.`issueF`,

`voterIssues`.`voterID`,

`VotingHistory`.`SuperVoter`

`VotingHistory`.`HVoterID`,

INNER JOIN `voters` ON (`voterIssues`.`voterID` = `voters`.`voterID`)

INNER JOIN `VotingHistory` ON (`VotingHistory`.`HVoterID` = `voters`.`voterID`)
Error from Within phpRunner ... I can't go past the edit SQL query:
Cannot retrieve columns information. Please modify SQL query and try again.

Error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to user near'. 'HVoterID'',

INNER JOIN 'voters' ON ('voterIssues'.'voterID' = 'voters'.'voter' at line 19
(note error message must be cut off because nowhere do I refer to a field voters.voter)
help?

J
Jane 7/26/2006

Karen,
please zip and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a full set of generated PHP files, your database creation script with sample data.

I'll find what's wrong with your project running it on my test box.

P
phpwalker author 7/26/2006

sent email with files...
thanks SOOOO much for any help you can give me...
Karen

P
phpwalker author 9/24/2006

Karen,

I'm sorry i gave you wrong link.

Here is article you need:

http://www.xlinesoft.com/phprunner/docs/us...sql_queries.htm
BTW, your issue is related to JOIN clause, not the Lookup wizard.


I am now trying to use version 3.1 and am getting the old "unknown column..." error... I used to have to open the include/dbcommon.php file and find function GetFullFieldName.
EXAMPLE.. Find a section that returns fullfield name for UserName field and put correct table name prefix there (replace Cars with Users).
if("Cars"==$table && $field=="Username") return "Users.UserName";
I guess I still need to do this in version 3.1?
Same steps apply?

J
Jane 9/25/2006

Hello, Karen
yes, you need to edit GetFullFieldName function in the include/commonfunctions.php file.