Author Topic: search help code rewite  (Read 971 times)

0 Members and 1 Guest are viewing this topic.

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
search help code rewite
« on: February 05, 2010, 01:21:17 AM »
working on the search and can't get it to work. I am trying

line 63 on index.php what I am tring to do is have is search by name or description


   $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `description` like '%%$search%%' OR 'name' like '%%$search%%' AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",

thoughs?
     
« Last Edit: February 05, 2010, 01:24:49 AM by winracer »
winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com

Offline hilflo

  • Full phpd Member
  • ***
  • Posts: 98
  • Karma: 2
  • Sorry for my bad english
    • View Profile
    • Les félés
Re: search help code rewite
« Reply #1 on: February 05, 2010, 11:51:41 AM »
And it don't work ?

Offline hilflo

  • Full phpd Member
  • ***
  • Posts: 98
  • Karma: 2
  • Sorry for my bad english
    • View Profile
    • Les félés
Re: search help code rewite
« Reply #2 on: February 05, 2010, 11:54:54 AM »
This code work for me

Code: [Select]
$search = $_POST['searching'];
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `name` like '%%$search%%' OR`description` like '%%$search%%' AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",
            SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
Re: search help code rewite
« Reply #3 on: February 05, 2010, 01:17:13 PM »
This code work for me

Code: [Select]
$search = $_POST['searching'];
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `name` like '%%$search%%' OR`description` like '%%$search%%' AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",
            SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());

yes that will work for me to but I want to search the name and the description fileds not just name. I have read and it says to use the or, but I can not get it to work.
Code: [Select]
  $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `description` like '%%$search%%' OR 'name' like '%%$search%%' AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",



thanks
winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com

Offline hilflo

  • Full phpd Member
  • ***
  • Posts: 98
  • Karma: 2
  • Sorry for my bad english
    • View Profile
    • Les félés
Re: search help code rewite
« Reply #4 on: February 05, 2010, 10:40:14 PM »
This code work for me

Code: [Select]
$search = $_POST['searching'];
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE [b]`name` like '%%$search%%' OR`description` like '%%$search%%'[/b] AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",
            SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());

yes that will work for me to but I want to search the name and the description fileds not just name. I have read and it says to use the or, but I can not get it to work.
Code: [Select]
  $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `description` like '%%$search%%' OR 'name' like '%%$search%%' AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",



thanks

It search if the name or the description is like the search.
If you want to search where the name and the description is like the search (I don't think thats a good way to search like that)
Try
Code: [Select]
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE (`description` like '%%$search%%' AND 'name' like '%%$search%%') AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
Re: search help code rewite
« Reply #5 on: February 06, 2010, 12:49:27 AM »
This code work for me

Code: [Select]
$search = $_POST['searching'];
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE [b]`name` like '%%$search%%' OR`description` like '%%$search%%'[/b] AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",
            SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());

yes that will work for me to but I want to search the name and the description fileds not just name. I have read and it says to use the or, but I can not get it to work.
Code: [Select]
  $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `description` like '%%$search%%' OR 'name' like '%%$search%%' AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",



thanks

It search if the name or the description is like the search.
If you want to search where the name and the description is like the search (I don't think thats a good way to search like that)
Try
Code: [Select]
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE (`description` like '%%$search%%' AND 'name' like '%%$search%%') AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",

yes I want the "or" if search is like name or description the return something. I don't want the "and" I think it is a bas idea to do the "and"


i was trying to fix so that the description would be search too.

thanks
winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com

Offline hilflo

  • Full phpd Member
  • ***
  • Posts: 98
  • Karma: 2
  • Sorry for my bad english
    • View Profile
    • Les félés
Re: search help code rewite
« Reply #6 on: February 06, 2010, 07:51:20 AM »
Use the fist code , it search in description too

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
Re: search help code rewite
« Reply #7 on: February 06, 2010, 03:57:51 PM »
thanks I got it I used

Code: [Select]
$search = $_POST[searching];
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `name` like '%%$search%%' OR`description` like '%%$search%%' OR`creator` like '%%$search%%'AND `approved` = '1' ORDER BY $sort $order1 LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());




and it works when you search, you search  name  or description or creator
for the search word... :)

thanks hilflo for you help

can view at http://www.myfunnypets.com/30/index.php

winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com