Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: power search?

  1. #1
    Join Date
    Nov 2004
    Posts
    1,822

    Default power search?

    How do I filter results, in power_search.php I added the following :

    $query .= " WHERE '$d_arriving' > $d_open AND '$d_arriving' < $d_closed " ;

    where: d_arriving = 1-02
    and d_open is 1-01 and d_closed is 1-12

    it shows up no results, i remove the line and it lists everything... therfore it seems to add the WHERE to the query, so I think I need to do something to get hte variables $d_open $d_closed from the database? how do i make reference to these variables?

  2. #2
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    You should add that line in correct order, please post your code.
    Try to remove "WHERE" and repleace it with AND

    $query .= " AND '$d_arriving' > $d_open AND '$d_arriving' < $d_closed " ;

    Still it depend on your position where you insert the code.

  3. #3
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Hey Dody, nice meeting you

    the code in context
    Code:
      // filter unhide
      $i=0;
      while($i<count($c)) { 
        $query .= " and category_id != $c[$i]";
        $i++;
      }  
      
    
      // filter member only
      if(!$users_obj->GetUserAuthentication()==0) {
    
        $i=0;
        while($i<count($c2)) { 
          $query .= " and category_id != $c2[$i]";
          $i++;
        }  
      }  
      // filter by date
     $query .= " WHERE '01-01'  > $d_open  AND '01-02' < $d_closed " ;
    I hard coded the date while i was testing it... is the position correct? its where all all the other ammendments to the query happened so i shoved it in

  4. #4
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    the problem is that you add WHERE statement, the above your code, indexu already include WHERE, so the query become incorrect if you add WHERE again.
    Please try to replace WHERE with AND as I mention before.

    $query .= " AND '01-01' > $d_open AND '01-02' < $d_closed " ;

    I do not know what is the field type (mysql) of d_open and d_close, if they're date then you need to compare as date format yyyymmdd.

  5. #5
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Quote Originally Posted by dody
    the problem is that you add WHERE statement, the above your code, indexu already include WHERE, so the query become incorrect if you add WHERE again.
    Please try to replace WHERE with AND as I mention before.

    $query .= " AND '01-01' > $d_open AND '01-02' < $d_closed " ;

    I do not know what is the field type (mysql) of d_open and d_close, if they're date then you need to compare as date format yyyymmdd.
    the type is varchar(5) I tried AND, this does not work. I added the variables to the reuslts page but they dont show up, so i thought that maybe the problem.
    I will play around with it a bit more and see if I can get it working, I didnt notice that it was WHERE above as well.

  6. #6
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    since it's a date, you can't compare it with string.
    You need to convert the field to date type and compare with the input from web form.

  7. #7
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    okay, well i think the problem is that i cant compare the values like i am

    1-12 < 1-13 it does not know how to compare like this. I did it this way as zubby said it was the best way for me (i did not need the year) now I have no idea what to do ...

  8. #8
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    hey 2 minutes quicker than me

    I dont actually need the year information, If i used the year it would need to be always the current year and i didnt think this would be possible without making everybody update the listigns each year ( thats never going to happen!) If i change to date field, then how will I make the year always current?

    anybody got a clever suggestion for this little problem

  9. #9
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    Email back zubby at zubby@nicecoder.com to discuss this problem

  10. #10
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Zubby for president!

    Works now: http://www.bigfreeguide.com/camping/...arch.php?cat=1
    Choosing a date after 01/10 removes my example listing.

    thanks for helping

  11. #11
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

  12. #12
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default

    May be you should do my next site !!!!

    Frank

  13. #13
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Quote Originally Posted by Frank71
    May be you should do my next site !!!!

    Frank

    Well Im happy to help anybody, if somebody sees something they dont know how to do that i have done on my site, then just PM me. Frank, if you want me to do the thumbnail changes on your new site then I said i would do it . no charge.

    The powersearch has a little bug in it (i have the fields stored DD-MM) so it thinks days are more important than months at the moment. I can fix that though.
    Last edited by inspireme; 01-28-2005 at 07:01 AM.

  14. #14
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

  15. #15
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default

    Hm, my problem is the time to setup the new site
    Still searching someone for the complete job (install and template changing)
    The flag mod is also nice and I like your checkboxes !

    Do you have a good idea for a travel design ?

    Frank

Similar Threads

  1. Power Search & Date Added
    By sweepsmaster in forum v5.x
    Replies: 4
    Last Post: 12-15-2004, 03:08 PM
  2. power search doesn't search certain cats
    By Rob Picken in forum v5.x
    Replies: 9
    Last Post: 06-15-2004, 02:03 PM
  3. Replies: 0
    Last Post: 02-13-2004, 08:56 PM
  4. Replies: 3
    Last Post: 10-02-2002, 12:58 PM
  5. Sorting using Power Search
    By vakil in forum v3.2
    Replies: 1
    Last Post: 10-01-2002, 11:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •