in reply to Search 2 columns
What DB do you use?
I'm sure this code must work:
SELECT name, address, city, phone FROM valley WHERE keywords LIKE '%Dealers%' OR category LIKE '%Dealers%' ORDER BY name
Please provide your real SQL code (which script send to SQL server).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search 2 columns
by JimJx (Beadle) on Sep 22, 2007 at 11:54 UTC | |
Thanks for looking!
| [reply] [d/l] |
by blokhead (Monsignor) on Sep 22, 2007 at 14:53 UTC | |
Consider the following things that can go wrong when generating your SQL: Solutions/suggestions: blokhead | [reply] [d/l] [select] |
by roboticus (Chancellor) on Sep 22, 2007 at 16:35 UTC | |
%$search ...roboticus | [reply] [d/l] |
by graff (Chancellor) on Sep 23, 2007 at 15:15 UTC | |
by roboticus (Chancellor) on Sep 23, 2007 at 15:50 UTC | |
by graff (Chancellor) on Sep 22, 2007 at 15:11 UTC | |
Your "if" statement is not testing whether $z equals zero -- you would need to use "==" to test that. But you also need to do that "if" statement after you try to push things onto @rows, not before. (See below.) Apart from that, I have a couple suggestions that I hope will make your life as a perl programmer more enjoyable... First, use placeholders in your queries -- they are so much better, in so many ways: (Updated to include the check for empty return from the DB.) Next, given that your query results are sorted by name, I don't know why you seem to want your html table to be organized like this: (Actually, I'm not sure what your intention is, but whatever...) Your loop for creating the table markup is probably broken. You start with @cells (and @cells2) containing 4 elements, and then do @cells="ugly string"; which reduces it to a single-element array, containing just the one "ugly string". (And you are referencing 5 elements in each row, where your query was only requesting 4.) There's a better way to code all that. Here's how I would arrange a simpler table: That has not been tested (I might not have it right), but if it's wrong, it should be easy to fix. And if you really want a more complicated table layout, it'll be easier to build from this simpler approach. Finally, the "x" operator will make it easier for you to get all those " " thingies to come out right, and your code will be easier to read and maintain:
| [reply] [d/l] [select] |
by JimJx (Beadle) on Sep 23, 2007 at 06:01 UTC | |
Atsa lotsa stuff! Thanks blokhead and graff! You both brought up some very good points, it is greatly appreciated. I am going to put in placeholders where I can. graff, that table code outputs 2 columns in the format One thing though, graff. Can you explain this section to me? I am not real sure that I am following the logic.
Thanks for everything guys! It is much appreciated and the points are well taken.
| [reply] [d/l] [select] |
by andreas1234567 (Vicar) on Sep 23, 2007 at 06:48 UTC | |
by graff (Chancellor) on Sep 23, 2007 at 19:38 UTC | |