Re: [PHP] search array

2013-04-11 Thread tamouse mailing lists
On Thu, Apr 11, 2013 at 1:37 PM, Russell Brackett
 wrote:
> I need help with this code to echo all items in the general database and not 
> just the fields I'm searching for.
>
> 
> // filter function
> function cleanInput($input) {
>
> $search = array('OEM Name, Category, OEM Name');
>
> $output = str_replace($search, '', $input);
> return $output;
> }
> //define layout name
> $layoutName = 'SYSTEMS CONFIGURATOR';
>
> //block for pagination
> if(isset($_GET['page']) && !empty($_GET['page'])){
> $page = $_GET['page'];
> }
> else{
> $page = 1;
> }
>
> $max = "20";
> $skip = ($page - 1) *  $max;
>
> // grab their search query and clean it
> if($_POST){
> $searchQuery= $_POST['q'];
> $_SESSION['searchQuery'] = $searchQuery;
> }
> else{
> if(!isset($_SESSION['searchQuery'])){
> header('location: index.php');
> }
> }
> //$searchQuery= "amat";
>
> // sanitize
> $cleanInput = cleanInput($_SESSION['searchQuery']);
>
> // Add 1st request for serial number
> $findSerial = $fm->newFindRequest($layoutName);
> $findSerial->addFindCriterion('OEM Name', $cleanInput);
>
>
> // Add 2nd request for category
> $findDesc = $fm->newFindRequest($layoutName);
> $findDesc->addFindCriterion('Category', $cleanInput);
> // search the description field
> //$find->addFindCriterion('description', $cleanInput);
>
> // sort the results
> //do a compound find with above two search conditions
> $compoundFind = $fm->newCompoundFindCommand($layoutName);
> $compoundFind->add(1, $findSerial);
> $compoundFind->add(2, $findDesc);
> $compoundFind->addSortRule('Serial #', 1, 
> FILEMAKER_SORT_ASCEND);
>
> // set skip and max values
> $compoundFind->setRange($skip, $max);
>
> // run the search
> $result = $compoundFind->execute();
> $records = $result->getRecords();
>
> //get found count and get total page number
> $foundCount = $result->getFoundSetCount();
> $totalPage = ceil($foundCount / $max);
>
> // create the smarty object
> $smarty = new Smarty();
> $smarty->force_compile = true;
> $smarty->debugging = false;
> $smarty->caching = false;
> //$smarty->cache_lifetime = 120;
> ?>
> Russell Brackett
> Web Developer
>
> Capitol Area Technology
> 3500 Comsouth Suite 500
> Austin, Texas, 78744
> rbrack...@capitolabs.com
> Office 512-610-3246
> Cell 979-412-3018
>
> Capitol Area Technology:
> Integrity-Courtesy-Customer Satisfaction
>

Where do these methods come from?

> // Add 1st request for serial number
> $findSerial = $fm->newFindRequest($layoutName);
> $findSerial->addFindCriterion('OEM Name', $cleanInput);
>
>
> // Add 2nd request for category
> $findDesc = $fm->newFindRequest($layoutName);
> $findDesc->addFindCriterion('Category', $cleanInput);
> // search the description field
> //$find->addFindCriterion('description', $cleanInput);
>
> // sort the results
> //do a compound find with above two search conditions
> $compoundFind = $fm->newCompoundFindCommand($layoutName);
> $compoundFind->add(1, $findSerial);
> $compoundFind->add(2, $findDesc);
> $compoundFind->addSortRule('Serial #', 1, 
> FILEMAKER_SORT_ASCEND);
>
> // set skip and max values
> $compoundFind->setRange($skip, $max);
>
> // run the search
> $result = $compoundFind->execute();

I'm not familiar with them as one of the usual PHP database extensions.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] search array

2013-04-11 Thread Russell Brackett
I need help with this code to echo all items in the general database and not 
just the fields I'm searching for.

newFindRequest($layoutName);
$findSerial->addFindCriterion('OEM Name', $cleanInput);


// Add 2nd request for category
$findDesc = $fm->newFindRequest($layoutName);
$findDesc->addFindCriterion('Category', $cleanInput);
// search the description field
//$find->addFindCriterion('description', $cleanInput);

// sort the results
//do a compound find with above two search conditions
$compoundFind = $fm->newCompoundFindCommand($layoutName);
$compoundFind->add(1, $findSerial);
$compoundFind->add(2, $findDesc);
$compoundFind->addSortRule('Serial #', 1, 
FILEMAKER_SORT_ASCEND);

// set skip and max values
$compoundFind->setRange($skip, $max);

// run the search
$result = $compoundFind->execute();
$records = $result->getRecords();

//get found count and get total page number
$foundCount = $result->getFoundSetCount();
$totalPage = ceil($foundCount / $max);

// create the smarty object
$smarty = new Smarty();
$smarty->force_compile = true;
$smarty->debugging = false;
$smarty->caching = false;
//$smarty->cache_lifetime = 120;
?>
Russell Brackett
Web Developer

Capitol Area Technology
3500 Comsouth Suite 500
Austin, Texas, 78744
rbrack...@capitolabs.com
Office 512-610-3246
Cell 979-412-3018

Capitol Area Technology:
Integrity-Courtesy-Customer Satisfaction



Re: Re: [PHP] Search for string followed by whitespace

2011-09-23 Thread Daniel Brown
On Fri, Sep 23, 2011 at 13:21, Tim Streater  wrote:
>
> Dan,
>
> Thanks for the suggestion but I need to know where the string occurs as I 
> want to then do some excision/incision.

Consider preg_replace() with that same pattern.  Or, at the most
involved, preg_replace_callback().

-- 

Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search for string followed by whitespace

2011-09-19 Thread Daniel Brown
On Sun, Sep 18, 2011 at 15:12, Tim Streater  wrote:
> At the moment, I'm doing this:
>
>   $start = stripos ($body, "
> You'll note the space after the ' for ' $loc'th character, and returning the location of the string in $start.
>
> I had a look at the PCRE and POSIX regexp functions to no avail. Is there a 
> slick way of doing this with one function call or should I just search for 
> '
> Thanks,

Try something along this line:



Replace $text with the text through which you want to look, and
your results will be an array in $matches.  The \b switch in the
regexp will match any word/letter border, which includes whitespaces,
tabs, newlines, periods, et cetera.  Essentially, anything that you'll
want to match inside HTML tags, be they valid or otherwise.  The U
modifier makes the search "Ungreedy," while the i modifier makes it
case-iNsEnSiTiVe.

-- 

Network Infrastructure Manager
http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search for string followed by whitespace

2011-09-18 Thread Tim Streater
At the moment, I'm doing this:

   $start = stripos ($body, "-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] search is not case insensitive

2010-11-02 Thread Tommy Pham
> -Original Message-
> From: tedd [mailto:tedd.sperl...@gmail.com]
> Sent: Tuesday, November 02, 2010 8:09 AM
> To: Tommy Pham; g...@holisticgp.com.au; php-general@lists.php.net
> Subject: RE: [PHP] search is not case insensitive
> 
> At 10:23 PM -0700 11/1/10, Tommy Pham wrote:
> >  > -Original Message-
> >>  From: tedd [mailto:tedd.sperl...@gmail.com]
> >>  Sent: Sunday, October 31, 2010 9:00 AM
> >>  To: g...@holisticgp.com.au; php-general@lists.php.net
> >>  Subject: Re: [PHP] search is not case insensitive
> >>
> >>  At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote:
> >>  >Hi
> >>  >Using a php search form produces a nil return on any information
> >>that
> >>  >is capitalised within a mysql database; retrieval is fine for
> >>  >non-capitalised data. Could someone tweak this please? The relevant
> >>  >code I think is as
> >>  >follows:
> >>  >
> >>  >// Description is a BLOB in MySQL... we need to UPPER the blob
> >>//values
> >>  >to make the search case-insensitive.
> >>  >
> >>  > $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id
> >>  AS user
> >>  >FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C
> >>".
> >>  >
> >>  > "WHERE A.id = B.user_id AND
> >>  >B.appointment_id = C.id  ".
> >>  >
> >>  > "AND LOWER(C.description) LIKE
> >>  >'%".strtolower($search_for)."%' AND
> >>  >C.start_time > $start_time AND C.start_time < $end_time ORDER BY
> >>  >C.start_time";
> >>  > $result = pbcs_db_query($query);
> >>  >
> >>  >Thanks
> >>  >Michael
> >>  >Melb, Aust.
> >>
> >>  Why are you using a BLOB?
> >>
> >>  You are just storing text data, right? If so, then a VARCHAR will
work.
> >>
> >>  Additionally, using a BLOB changes things somewhat in that all data
> >> are  stored as binary strings and as such makes all comparisons case-
> sensitive.
> >>  Too many double negatives for me.
> >>
> >>  Cheers,
> >>
> >>  tedd
> >>  --
> >>  ---
> >>  http://sperling.com/
> >>
> >
> >IIRC, the VARCHAR (for MySQL) has a limit of 255 chars.  You may have
> >to use one of the *TEXT variants if you need to store a lot of text.
> >
> >Regards,
> >Tommy
> 
> Tommy:
> 
> If you are using a version of MySQL that is older than v 5.0.3, then you
are
> right -- but after that version VARCHAR can hold up to 65,535 characters.

Tedd,

That tells you that I haven't been keeping track of version changes for
MySQL.  I remember that when 5 was still an RC.

> How much does the OP need?
> 
> If that is not enough room, then why not use LONGTEXT (4G)?
> 
> The differences are how the data is stored. In BLOBS the data is stored in
> binary strings with no char set and comparisons are based on numeric
values
> of bytes. Whereas, TEXT data are treated as character strings which have a
> char set and can be sorted and compared based upon collation of the char
> set.
> 
> Cheers,
> 
> tedd
> 
> 
> --
> ---
> http://sperling.com/

I totally agree on VARCHAR/TEXT over BLOBs as you can use the index
(with/without FULLTEXT) more efficiently for faster query results.

Regards,
Tommy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] search is not case insensitive

2010-11-02 Thread tedd

At 10:23 PM -0700 11/1/10, Tommy Pham wrote:

 > -Original Message-

 From: tedd [mailto:tedd.sperl...@gmail.com]
 Sent: Sunday, October 31, 2010 9:00 AM
 To: g...@holisticgp.com.au; php-general@lists.php.net
 Subject: Re: [PHP] search is not case insensitive

 At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote:
 >Hi
 >Using a php search form produces a nil return on any information that
 >is capitalised within a mysql database; retrieval is fine for
 >non-capitalised data. Could someone tweak this please? The relevant
 >code I think is as
 >follows:
 >
 >// Description is a BLOB in MySQL... we need to UPPER the blob //values
 >to make the search case-insensitive.
 >
 >   $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id
 AS user
 >FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C
".
 >
 >   "WHERE A.id = B.user_id AND
 >B.appointment_id = C.id".
 >
 >   "AND LOWER(C.description) LIKE
 >'%".strtolower($search_for)."%' AND
 >C.start_time > $start_time AND C.start_time < $end_time ORDER BY
 >C.start_time";
 >   $result = pbcs_db_query($query);
 >
 >Thanks
 >Michael
 >Melb, Aust.

 Why are you using a BLOB?

 You are just storing text data, right? If so, then a VARCHAR will work.

 Additionally, using a BLOB changes things somewhat in that all data are
 stored as binary strings and as such makes all comparisons case-sensitive.
 Too many double negatives for me.

 Cheers,

 tedd
 --
 ---
 http://sperling.com/



IIRC, the VARCHAR (for MySQL) has a limit of 255 chars.  You may have to use
one of the *TEXT variants if you need to store a lot of text.

Regards,
Tommy


Tommy:

If you are using a version of MySQL that is older than v 5.0.3, then 
you are right -- but after that version VARCHAR can hold up to 65,535 
characters. How much does the OP need?


If that is not enough room, then why not use LONGTEXT (4G)?

The differences are how the data is stored. In BLOBS the data is 
stored in binary strings with no char set and comparisons are based 
on numeric values of bytes. Whereas, TEXT data are treated as 
character strings which have a char set and can be sorted and 
compared based upon collation of the char set.


Cheers,

tedd


--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] search is not case insensitive

2010-11-01 Thread Tommy Pham
> -Original Message-
> From: tedd [mailto:tedd.sperl...@gmail.com]
> Sent: Sunday, October 31, 2010 9:00 AM
> To: g...@holisticgp.com.au; php-general@lists.php.net
> Subject: Re: [PHP] search is not case insensitive
> 
> At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote:
> >Hi
> >Using a php search form produces a nil return on any information that
> >is capitalised within a mysql database; retrieval is fine for
> >non-capitalised data. Could someone tweak this please? The relevant
> >code I think is as
> >follows:
> >
> >// Description is a BLOB in MySQL... we need to UPPER the blob //values
> >to make the search case-insensitive.
> >
> > $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id
> AS user
> >FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C
>   ".
> >
> > "WHERE A.id = B.user_id AND
> >B.appointment_id = C.id  ".
> >
> > "AND LOWER(C.description) LIKE
> >'%".strtolower($search_for)."%' AND
> >C.start_time > $start_time AND C.start_time < $end_time ORDER BY
> >C.start_time";
> > $result = pbcs_db_query($query);
> >
> >Thanks
> >Michael
> >Melb, Aust.
> 
> Why are you using a BLOB?
> 
> You are just storing text data, right? If so, then a VARCHAR will work.
> 
> Additionally, using a BLOB changes things somewhat in that all data are
> stored as binary strings and as such makes all comparisons case-sensitive.
> Too many double negatives for me.
> 
> Cheers,
> 
> tedd
> --
> ---
> http://sperling.com/
> 

IIRC, the VARCHAR (for MySQL) has a limit of 255 chars.  You may have to use
one of the *TEXT variants if you need to store a lot of text.

Regards,
Tommy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] search is not case insensitive

2010-11-01 Thread Tommy Pham
> -Original Message-
> From: a...@ashleysheridan.co.uk [mailto:a...@ashleysheridan.co.uk]
> Sent: Sunday, October 31, 2010 2:10 AM
> To: Dr Michael Daly; php-general@lists.php.net
> Subject: Re: [PHP] search is not case insensitive
> 
> This isn't a php question but a mysql one. Take out the lower() part of the
> sql statement, as like is case insensitive by default.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> - Reply message -
> From: "Dr Michael Daly" 
> Date: Sun, Oct 31, 2010 04:47
> Subject: [PHP] search is not case insensitive
> To: 
> 
> Hi
> Using a php search form produces a nil return on any information that is
> capitalised within a mysql database; retrieval is fine for non-capitalised
> data. Could someone tweak this please? The relevant code I think is as
> follows:
> 
> // Description is a BLOB in MySQL... we need to UPPER the blob //values to
> make the search case-insensitive.
> 
>   $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id
> AS user
> FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C  ".
> 
>   "WHERE A.id = B.user_id AND
> B.appointment_id = C.id   ".
> 
>   "AND LOWER(C.description) LIKE
> '%".strtolower($search_for)."%' AND C.start_time > $start_time AND
> C.start_time < $end_time ORDER BY C.start_time";
>   $result = pbcs_db_query($query);
> 
> Thanks
> Michael
> Melb, Aust.
> 

You could also remove the strtolower().  Just to be sure that field 
C.description is set with case-insensitive collation, you could use phpMyAdmin 
to look at the table structure or run SQL 'show create table pbcs_appointment;' 
on your MySQL tool.  The description column should have *_ci (for 
case-insensitive whereas *_cs is case-sensitive).

Regards,
Tommy


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] search is not case insensitive

2010-10-31 Thread tedd

At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote:

Hi
Using a php search form produces a nil return on any information that is
capitalised within a mysql database; retrieval is fine for non-capitalised
data. Could someone tweak this please? The relevant code I think is as
follows:

// Description is a BLOB in MySQL... we need to UPPER the blob
//values to make the search case-insensitive.

$query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user
FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C".

"WHERE A.id = B.user_id AND 
B.appointment_id = C.id	".


"AND LOWER(C.description) LIKE 
'%".strtolower($search_for)."%' AND

C.start_time > $start_time AND C.start_time < $end_time ORDER BY
C.start_time";
$result = pbcs_db_query($query);

Thanks
Michael
Melb, Aust.


Why are you using a BLOB?

You are just storing text data, right? If so, then a VARCHAR will work.

Additionally, using a BLOB changes things somewhat in that all data 
are stored as binary strings and as such makes all comparisons 
case-sensitive. Too many double negatives for me.


Cheers,

tedd
--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] search is not case insensitive

2010-10-31 Thread Dr Michael Daly
thanks for this Ash...I didn't really understand but I do now!

unfortunately the fix didn't work, possibly bec the mysql data is in
binary format (default then becomes: case sensitive). I got a 'syntax
error' result

I'll find a mysql forum

Michael


This isn't a php question but a mysql one. Take out the lower() part of
the sql statement, as like is case insensitive by default.

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "Dr Michael Daly" 
Date: Sun, Oct 31, 2010 04:47
Subject: [PHP] search is not case insensitive
To: 

Hi
Using a php search form produces a nil return on any information that is
capitalised within a mysql database; retrieval is fine for non-capitalised
data. Could someone tweak this please? The relevant code I think is as
follows:

// Description is a BLOB in MySQL... we need to UPPER the blob
//values to make the search case-insensitive.

$query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user
FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C".

"WHERE A.id = B.user_id AND B.appointment_id = 
C.id ".

"AND LOWER(C.description) LIKE 
'%".strtolower($search_for)."%' AND
C.start_time > $start_time AND C.start_time < $end_time ORDER BY
C.start_time";
$result = pbcs_db_query($query);

Thanks
Michael
Melb, Aust.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Dr Michael Daly MB, BS
GradDip(Integrative Medicine), GradCert(Evidence Based Practice),
M Bus(Information Innovation), GradDip(Document Management)
03 9521 0352
0413 879 029

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] search is not case insensitive

2010-10-31 Thread a...@ashleysheridan.co.uk
This isn't a php question but a mysql one. Take out the lower() part of the sql 
statement, as like is case insensitive by default.

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "Dr Michael Daly" 
Date: Sun, Oct 31, 2010 04:47
Subject: [PHP] search is not case insensitive
To: 

Hi
Using a php search form produces a nil return on any information that is
capitalised within a mysql database; retrieval is fine for non-capitalised
data. Could someone tweak this please? The relevant code I think is as
follows:

// Description is a BLOB in MySQL... we need to UPPER the blob
//values to make the search case-insensitive.

$query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user
FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C".

"WHERE A.id = B.user_id AND B.appointment_id = 
C.id ".

"AND LOWER(C.description) LIKE 
'%".strtolower($search_for)."%' AND
C.start_time > $start_time AND C.start_time < $end_time ORDER BY
C.start_time";
$result = pbcs_db_query($query);

Thanks
Michael
Melb, Aust.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] search is not case insensitive

2010-10-30 Thread Dr Michael Daly
Hi
Using a php search form produces a nil return on any information that is
capitalised within a mysql database; retrieval is fine for non-capitalised
data. Could someone tweak this please? The relevant code I think is as
follows:

// Description is a BLOB in MySQL... we need to UPPER the blob
//values to make the search case-insensitive.

$query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user
FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C".

"WHERE A.id = B.user_id AND B.appointment_id = 
C.id ".

"AND LOWER(C.description) LIKE 
'%".strtolower($search_for)."%' AND
C.start_time > $start_time AND C.start_time < $end_time ORDER BY
C.start_time";
$result = pbcs_db_query($query);

Thanks
Michael
Melb, Aust.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search inside file :)

2010-10-11 Thread Jordan Jovanov

Hello everybody,

I create one site where user can upload .zip files, but now I have one 
interesting problem. I need me PHP script where can have one edit box 
and button, user can input same text in edit box and when press on 
button he need to find the document who have text from edit button.
Do you same body have script or more on script who can search inside in 
same file (zip file with word document, presentation etc).


Thanks a lot. :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working (RESOLVED)

2009-07-21 Thread Miller, Terion

Yep, sure was the spacesOMG...will I ever get it...

On 7/21/09 12:29 PM, "Ashley Sheridan"  wrote:

On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote:
> On Tue, Jul 21, 2009 at 1:20 PM, Miller,
> Terion wrote:
> > Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> > which is prob messing it up right...but in the code why is it doing that 
> > twice..
> >
> > SELECT name, address, inDate, inType, notes, critical, cviolations, 
> > noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> > restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> > restaurants.name LIKE '%A%' ORDER BY restaurants.name;
> >
> >
>
> It's not the multiple LIKE statements. It is the concatenation, like I
> said the last time. There is no white space between "inspection.ID"
> and "AND".
>
> You may indeed have problems with some of those repeated conditions on
> restaurants.name, but if so they will be performance issues resulting
> from table scans, and not the errors you are reporting.
>
> Andrew
>

It's always better putting in extra whitespace at both ends of each part
of the query you are concatenating if you're unsure. Like Andrew said,
MySQL will balk if you have none between keywords, but I've never heard
it complaining about an extra space or two!

Thanks
Ash
www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote:
> On Tue, Jul 21, 2009 at 1:20 PM, Miller,
> Terion wrote:
> > Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> > which is prob messing it up right...but in the code why is it doing that 
> > twice..
> >
> > SELECT name, address, inDate, inType, notes, critical, cviolations, 
> > noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> > restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> > restaurants.name LIKE '%A%' ORDER BY restaurants.name;
> >
> >
> 
> It's not the multiple LIKE statements. It is the concatenation, like I
> said the last time. There is no white space between "inspection.ID"
> and "AND".
> 
> You may indeed have problems with some of those repeated conditions on
> restaurants.name, but if so they will be performance issues resulting
> from table scans, and not the errors you are reporting.
> 
> Andrew
> 

It's always better putting in extra whitespace at both ends of each part
of the query you are concatenating if you're unsure. Like Andrew said,
MySQL will balk if you have none between keywords, but I've never heard
it complaining about an extra space or two!

Thanks
Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote:
> 
> 
> On 7/21/09 11:47 AM, "Dan Shirah"  wrote:
> 
> Why isn't this working for searching?
> 
>   // Run query on submitted values. Store results in $SESSION and redirect to 
> restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
> critical, cviolations, noncritical FROM restaurants, inspections WHERE 
> restaurants.name   <> '' 
> AND restaurant.ID = inspection.ID";if ($searchName){ $sql .= "AND 
> restaurants.name   LIKE 
> '%". mysql_real_escape_string($name) ."%' ";if(count($name2) == 1)
> {$sql .= "AND restaurants.name 
>   LIKE '%". 
> mysql_real_escape_string($name2[1]) ."%' ";}else{
> foreach($name2 as $namePart){$sql .= "AND restaurants.name 
>   LIKE '%". 
> mysql_real_escape_string($namePart) ."%' ";}}}if 
> ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER 
> BY restaurants.name  ;";  
>   $result = mysql_query($sql);
> I'm not sure about MySQL, but in Informix my queries will crash when trying 
> to just append the ORDER BY clause by itself.
> 
> $sql .= "ORDER BY restaurants.name 
>  ;";
> 
> Also, you have a semi colon before and after the ending quote.
> 
> TRY
> 
> $sql .= "AND 1 = 1
> ORDER BY restaurants.name  
> ";
> 
> 
> 
> 
> 
> 
> 
> Got the query to this point now:
> 
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
>  on line 119
> 
That means your query is invalid. Try printing the query out and posting
it here so that we can see it.

Thanks
Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Andrew Ballard
On Tue, Jul 21, 2009 at 1:20 PM, Miller,
Terion wrote:
> Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> which is prob messing it up right...but in the code why is it doing that 
> twice..
>
> SELECT name, address, inDate, inType, notes, critical, cviolations, 
> noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> restaurants.name LIKE '%A%' ORDER BY restaurants.name;
>
>

It's not the multiple LIKE statements. It is the concatenation, like I
said the last time. There is no white space between "inspection.ID"
and "AND".

You may indeed have problems with some of those repeated conditions on
restaurants.name, but if so they will be performance issues resulting
from table scans, and not the errors you are reporting.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 10:07 -0700, Miller, Terion wrote:
> 
> 
> On 7/21/09 12:04 PM, "Ashley Sheridan"  wrote:
> 
> On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote:
> >
> >
> > On 7/21/09 11:47 AM, "Dan Shirah"  wrote:
> >
> > Why isn't this working for searching?
> >
> >   // Run query on submitted values. Store results in $SESSION and redirect 
> > to restaurants.php$sql = "SELECT name, address, inDate, inType, 
> > notes, critical, cviolations, noncritical FROM restaurants, inspections 
> > WHERE restaurants.name 
> > 
> >   <> '' AND restaurant.ID = inspection.ID";if ($searchName){ 
> > $sql .= "AND restaurants.name 
> > 
> >   LIKE '%". mysql_real_escape_string($name) ."%' ";if(count($name2) 
> > == 1){$sql .= "AND restaurants.name 
> > 
> >   LIKE '%". mysql_real_escape_string($name2[1]) ."%' ";}else{   
> >  foreach($name2 as $namePart){$sql .= "AND 
> > restaurants.name 
> > 
> >   LIKE '%". mysql_real_escape_string($namePart) ."%' ";}}}  
> >   if ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> > mysql_real_escape_string($address) ."%' ";}   $sql .= 
> > "ORDER BY restaurants.name 
> > 
> >  ;";$result = mysql_query($sql);
> > I'm not sure about MySQL, but in Informix my queries will crash when trying 
> > to just append the ORDER BY clause by itself.
> >
> > $sql .= "ORDER BY restaurants.name 
> > 
> >  ;";
> >
> > Also, you have a semi colon before and after the ending quote.
> >
> > TRY
> >
> > $sql .= "AND 1 = 1
> > ORDER BY restaurants.name 
> > 
> >  ";
> >
> >
> >
> >
> >
> >
> >
> > Got the query to this point now:
> >
> > Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
> > resource in 
> > /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
> >  on line 119
> >
> That means your query is invalid. Try printing the query out and posting
> it here so that we can see it.
> 
> Thanks
> Ash
> www.ashleysheridan.co.uk
> 
> 
> 
> I Got this error when I echo'd the sql $results ;
> You have an error in your SQL syntax; check the manual that corresponds to 
> your MySQL server version for the right syntax to use near 'restaurants.name 
> LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants' at line 1
> 
Yes, but that's not your query. The problem is with your query. If you
echo the query, we can see where it might be falling over.

Thanks
Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion
Here it is...I see where it's doing the restaurant.name LIKE statement 2x which 
is prob messing it up right...but in the code why is it doing that twice..

SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical 
FROM restaurants, inspections WHERE restaurants.name <> '' AND restaurant.ID = 
inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' 
ORDER BY restaurants.name;


On 7/21/09 12:11 PM, "Dan Shirah"  wrote:

print_r($sql);


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Dan Shirah
On Tue, Jul 21, 2009 at 12:41 PM, Miller, Terion <
tmil...@springfi.gannett.com> wrote:

> Turned off the redirects on the whole script and tried to the the query to
> echo and these are the errors I got:
>
> Notice: Undefined offset: 1 in /var/www/vhosts/
> getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon
>  line 89
>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
> resource in /var/www/vhosts/
> getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon
>  line 119
>
>
> On 7/21/09 11:32 AM, "Kevin Smith"  wrote:
>
> Can you supply the actual generated SQL, I can potentially see a
> problem, but need to see the final SQL statement.
>
> print_r($sql);


Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion
Turned off the redirects on the whole script and tried to the the query to echo 
and these are the errors I got:

Notice: Undefined offset: 1 in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
 on line 89

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
 on line 119


On 7/21/09 11:32 AM, "Kevin Smith"  wrote:

Can you supply the actual generated SQL, I can potentially see a
problem, but need to see the final SQL statement.

Miller, Terion wrote:
> Why isn't this working for searching?
>
> // Run query on submitted values. Store results in $SESSION and redirect 
> to restaurants.php$sql = "SELECT name, address, inDate, inType, 
> notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE 
> restaurants.name<>  '' AND restaurant.ID = inspection.ID";if 
> ($searchName){ $sql .= "AND restaurants.name LIKE '%". 
> mysql_real_escape_string($name) ."%' ";if(count($name2) == 1){
> $sql .= "AND restaurants.name LIKE '%". 
> mysql_real_escape_string($name2[1]) ."%' ";}else{
> foreach($name2 as $namePart){$sql .= "AND restaurants.name 
> LIKE '%". mysql_real_escape_string($namePart) ."%' ";}}}
> if ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER 
> BY restaurants.name;";$result = mysql_query($sql);
>
>





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion



On 7/21/09 12:04 PM, "Ashley Sheridan"  wrote:

On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote:
>
>
> On 7/21/09 11:47 AM, "Dan Shirah"  wrote:
>
> Why isn't this working for searching?
>
>   // Run query on submitted values. Store results in $SESSION and redirect to 
> restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
> critical, cviolations, noncritical FROM restaurants, inspections WHERE 
> restaurants.name 
> 
>   <> '' AND restaurant.ID = inspection.ID";if ($searchName){ $sql 
> .= "AND restaurants.name 
> 
>   LIKE '%". mysql_real_escape_string($name) ."%' ";if(count($name2) 
> == 1){$sql .= "AND restaurants.name 
> 
>   LIKE '%". mysql_real_escape_string($name2[1]) ."%' ";}else{ 
>foreach($name2 as $namePart){$sql .= "AND restaurants.name 
> 
>   LIKE '%". mysql_real_escape_string($namePart) ."%' ";}}}
> if ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER 
> BY restaurants.name 
> 
>  ;";$result = mysql_query($sql);
> I'm not sure about MySQL, but in Informix my queries will crash when trying 
> to just append the ORDER BY clause by itself.
>
> $sql .= "ORDER BY restaurants.name 
> 
>  ;";
>
> Also, you have a semi colon before and after the ending quote.
>
> TRY
>
> $sql .= "AND 1 = 1
> ORDER BY restaurants.name 
> 
>  ";
>
>
>
>
>
>
>
> Got the query to this point now:
>
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
>  on line 119
>
That means your query is invalid. Try printing the query out and posting
it here so that we can see it.

Thanks
Ash
www.ashleysheridan.co.uk



I Got this error when I echo'd the sql $results ;
You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near 'restaurants.name LIKE 
'%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants' at line 1

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion



On 7/21/09 11:47 AM, "Dan Shirah"  wrote:

Why isn't this working for searching?

  // Run query on submitted values. Store results in $SESSION and redirect to 
restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
critical, cviolations, noncritical FROM restaurants, inspections WHERE 
restaurants.name   <> '' 
AND restaurant.ID = inspection.ID";if ($searchName){ $sql .= "AND 
restaurants.name   LIKE 
'%". mysql_real_escape_string($name) ."%' ";if(count($name2) == 1){ 
   $sql .= "AND restaurants.name 
  LIKE '%". 
mysql_real_escape_string($name2[1]) ."%' ";}else{
foreach($name2 as $namePart){$sql .= "AND restaurants.name 
  LIKE '%". 
mysql_real_escape_string($namePart) ."%' ";}}}if 
($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER BY 
restaurants.name  ;";   
 $result = mysql_query($sql);
I'm not sure about MySQL, but in Informix my queries will crash when trying to 
just append the ORDER BY clause by itself.

$sql .= "ORDER BY restaurants.name 
 ;";

Also, you have a semi colon before and after the ending quote.

TRY

$sql .= "AND 1 = 1
ORDER BY restaurants.name  ";







Got the query to this point now:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
 on line 119

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Dan Shirah
>
> Why isn't this working for searching?
>
>   // Run query on submitted values. Store results in $SESSION and redirect
> to restaurants.php$sql = "SELECT name, address, inDate, inType,
> notes, critical, cviolations, noncritical FROM restaurants, inspections
> WHERE restaurants.name <> '' AND restaurant.ID = inspection.ID";if
> ($searchName){ $sql .= "AND restaurants.name LIKE '%".
> mysql_real_escape_string($name) ."%' ";if(count($name2) == 1){
>  $sql .= "AND restaurants.name LIKE '%".
> mysql_real_escape_string($name2[1]) ."%' ";}else{
>  foreach($name2 as $namePart){$sql .= "AND
> restaurants.name LIKE '%". mysql_real_escape_string($namePart) ."%' ";
>}}}if ($searchAddress) {$sql .= "AND
> restaurants.address LIKE '%". mysql_real_escape_string($address) ."%' ";
>  }   $sql .= "ORDER BY restaurants.name;";
>  $result = mysql_query($sql);
>
I'm not sure about MySQL, but in Informix my queries will crash when trying
to just append the ORDER BY clause by itself.

$sql .= "ORDER BY restaurants.name;";

Also, you have a semi colon before and after the ending quote.

TRY

$sql .= "AND 1 = 1
ORDER BY restaurants.name";


Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Andrew Ballard
On Tue, Jul 21, 2009 at 12:26 PM, Miller,
Terion wrote:
> Why isn't this working for searching?

Check your concatenation in the query. You need some white space
padding your SQL segments, otherwise the text all starts to run
together.

 (I had to reformat it. For some reason, most of the code snippets you
post end up all run together on a single line, at least in Gmail.)

 ''
AND restaurant.ID = inspection.ID";

  if ($searchName){
// ADDED SPACE HERE
  $sql .= " AND restaurants.name LIKE '%".
mysql_real_escape_string($name) ."%' ";
  if(count($name2) == 1){
// ADDED SPACE HERE
  $sql .= " AND restaurants.name LIKE '%".
mysql_real_escape_string($name2[1]) ."%' ";
  }else{
  foreach($name2 as $namePart){
// ADDED SPACE HERE
  $sql .= " AND restaurants.name LIKE '%".
mysql_real_escape_string($namePart) ."%' ";
  }
  }
  }

  if ($searchAddress) {
// ADDED SPACE HERE
  $sql .= " AND restaurants.address LIKE '%".
mysql_real_escape_string($address) ."%' ";
  }
// ADDED SPACE HERE
  $sql .= " ORDER BY restaurants.name;";
  $result = mysql_query($sql);


Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion
Why isn't this working for searching?

   // Run query on submitted values. Store results in $SESSION and redirect to 
restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
critical, cviolations, noncritical FROM restaurants, inspections WHERE 
restaurants.name <> '' AND restaurant.ID = inspection.ID";if ($searchName)  
  { $sql .= "AND restaurants.name LIKE '%". mysql_real_escape_string($name) 
."%' ";if(count($name2) == 1){$sql .= "AND restaurants.name 
LIKE '%". mysql_real_escape_string($name2[1]) ."%' ";}else{
foreach($name2 as $namePart){$sql .= "AND restaurants.name LIKE 
'%". mysql_real_escape_string($namePart) ."%' ";}}}if 
($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER BY 
restaurants.name;";$result = mysql_query($sql);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search/Replace in entire database?

2009-06-15 Thread tedd

At 9:17 PM -0700 6/14/09, Chris Payne wrote:

Hi everyone,

I am in the middle of creating an editor where you can search and
replace on an individual column in a single table then I came across
something I need to be able to do but not sure how.

Is it posible (And if so please how :-) to search an entire database
and all tables within a database and do a find/replace on keywords
without having to specify each table/column within that table?

The people I am working for have made some big changes and one of them
is changing the names of one of their products, but this product name
appears EVERYWHERE in many tables and in lots of different column
names, and it would save so much time if I could do a single query
that would just search EVERYTHING within the database.

Thanks for any advice you can give me.

Regards

Chris Payne


Chris:

The problem you cite is exactly why one should use relational 
databases. If the people you are working for had done that, then you 
would have only to edit one table.


The process works like this -- you have a product table that has an 
unique id with other information about each product, such as its 
name. However, every table that references that product does so via 
the product's id and not the product's name. As such, each look-up 
for the product name requires first to know the product's id and then 
pull out the name associated with that id.


In any event, a little more work at the start saves tons later.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search/Replace in entire database?

2009-06-15 Thread Caner Bulut
Hi Chris,

MySQL introduced full - text indexing and searching capabilities back in
version 3.23.23. The implementation is straightforward and easy to use —
define a FULLTEXT index and use MATCH / AGAINST in the query. Consider this
example:

CREATE TABLE SOCIAL_EVENT (
EVENT_ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
USER_ID INTEGER UNSIGNED NOT NULL,
HEADLINE TEXT NOT NULL,
EVENT_TEXT TEXT NOT NULL,
EVENT_DATE TIMESTAMP NOT NULL,

PRIMARY KEY (EVENT_ID),

FOREIGN KEY (USER_ID)

REFERENCES SOCIAL_USER(USER_ID),

FULLTEXT INDEX (HEADLINE, EVENT_TEXT)

)

ENGINE=MyISAM DEFAULT CHARACTER SET latin1
COLLATE latin1_general_cs AUTO_INCREMENT=0;

Thanks.
Caner

2009/6/15 Chris Payne 

> Hi everyone,
>
> I am in the middle of creating an editor where you can search and
> replace on an individual column in a single table then I came across
> something I need to be able to do but not sure how.
>
> Is it posible (And if so please how :-) to search an entire database
> and all tables within a database and do a find/replace on keywords
> without having to specify each table/column within that table?
>
> The people I am working for have made some big changes and one of them
> is changing the names of one of their products, but this product name
> appears EVERYWHERE in many tables and in lots of different column
> names, and it would save so much time if I could do a single query
> that would just search EVERYTHING within the database.
>
> Thanks for any advice you can give me.
>
> Regards
>
> Chris Payne
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Search/Replace in entire database?

2009-06-14 Thread Chris Payne
Hi everyone,

I am in the middle of creating an editor where you can search and
replace on an individual column in a single table then I came across
something I need to be able to do but not sure how.

Is it posible (And if so please how :-) to search an entire database
and all tables within a database and do a find/replace on keywords
without having to specify each table/column within that table?

The people I am working for have made some big changes and one of them
is changing the names of one of their products, but this product name
appears EVERYWHERE in many tables and in lots of different column
names, and it would save so much time if I could do a single query
that would just search EVERYTHING within the database.

Thanks for any advice you can give me.

Regards

Chris Payne

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search functionality in website.

2008-12-29 Thread tedd

At 8:17 PM +0530 12/29/08, Tiji varghese wrote:
Hi all,I would like to set up search functionality on my website. 
I'm using PHP and Mysql. Most of the pages contain static text in 
the html and is not database driven. I need some idea on how should 
I go about it without moving everything to database driven 
functionality. Please help.Thanks in advance!


Try:

http://sperling.com/examples/search/

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search functionality in website.

2008-12-29 Thread Richard Heyes
> Hi all,I would like to set up search functionality on my website. I'm using 
> PHP and Mysql. Most
> of the pages contain static text in the html and is not database driven. I 
> need some idea on how
> should I go about it without moving everything to database driven 
> functionality.

You could look into using Zend_Search_Lucene (part of the Zend
framework). Never used it myself, but from what I've read about it, it
looks quite good (plus it's file based, ie. you don't need MySQL).
There's also the Google search widget like I use on my personal
website: http://www.phpguru.org

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated December 20th)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search functionality in website.

2008-12-29 Thread John Corry
Or even a google search widget...

Miles Thompson wrote:
> On Mon, Dec 29, 2008 at 10:47 AM, Tiji varghese  wrote:

> ht-dig (or digg)
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search functionality in website.

2008-12-29 Thread Miles Thompson
On Mon, Dec 29, 2008 at 10:47 AM, Tiji varghese  wrote:

> Hi all,I would like to set up search functionality on my website. I'm using
> PHP and Mysql. Most of the pages contain static text in the html and is not
> database driven. I need some idea on how should I go about it without moving
> everything to database driven functionality. Please help.Thanks in advance!
>
>
>  Add more friends to your messenger and enjoy! Go to
> http://messenger.yahoo.com/invite/


ht-dig (or digg)


[PHP] Search functionality in website.

2008-12-29 Thread Tiji varghese
Hi all,I would like to set up search functionality on my website. I'm using PHP 
and Mysql. Most of the pages contain static text in the html and is not 
database driven. I need some idea on how should I go about it without moving 
everything to database driven functionality. Please help.Thanks in advance! 


  Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/

Re: [PHP] search for person by comparing his data with data in mysql

2008-12-20 Thread Andrew Ballard
On Sat, Dec 20, 2008 at 7:01 AM, Jochem Maas  wrote:
> c...@l-i-e.com schreef:
>> select
>>   first_name like '%$first_name%'
>> + 3 * last_name like '%$last_name%'
>> + 7 * email = '$email'
>> as score,
>
> that works?? I guess the expressions (e.g. email = '$email')
> evaluate to bools and are auto-cast to ints.
>
> Im guess there needs to be some parenthesis in there somewhere, no?
>
> anyway nice snippet :-)
>

If it works, it must be a MySQL "feature".

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] search for person by comparing his data with data in mysql

2008-12-20 Thread Jochem Maas
c...@l-i-e.com schreef:
> select 
>   first_name like '%$first_name%' 
> + 3 * last_name like '%$last_name%'
> + 7 * email = '$email'
> as score,

that works?? I guess the expressions (e.g. email = '$email')
evaluate to bools and are auto-cast to ints.

Im guess there needs to be some parenthesis in there somewhere, no?

anyway nice snippet :-)

> first_name, last_name, email, person_id
> from person
> .
> .
> .
> order by score desc
> limit 10
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] search for person by comparing his data with data in mysql

2008-12-19 Thread ceo

select 

  first_name like '%$first_name%' 

+ 3 * last_name like '%$last_name%'

+ 7 * email = '$email'

as score,

first_name, last_name, email, person_id

from person

.

.

.

order by score desc

limit 10



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] search for person by comparing his data with data in mysql

2008-12-19 Thread Afan Pasalic

hi,
I have to build a little "search" form.
a visitor enters his/her personal and work data (first name, last name, 
email, org. name, phones (home phone, work phone, cell) home address, 
work address) using a form, and then administrator has to compare these 
data with existing data in database (mysql). if record in database has 
the same first name as the visitor, the record will get 1 point. if the 
last name is the same - 3 points. if both names are the same - clearly 4 
points. if email matches 7 points, phone number 4 points, etc.


the list to be shown on the screen is list of all records they have at 
least 1 point. and the list has to be sorted by number of points.


also, matching parts on the list have to be highlighted (with different 
background color, of the font different color).


I did some testing and the code is really basic, using LIKE, and I'm 
assuming not so good way. first, I'll get all records from database. 
while "reading" I compare data from DB with visitor's data. my query 
(simplified) looks something like this




$query = "
   SELECT p.person_id, p.first_name, p.last_name, p.phone as 
phone_home, p.primary_org, p.address_id, p.email as personal_email, 
o.full_name, o.organization_id, o.phone as phone_work, o.address_id as 
org_address, a.address1, a.city, a.state, a.zip, a.county

   FROM people p
   LEFT JOIN organization o ON 
(o.instance=".$_SESSION['instance']." AND 
o.organization_id=p.organization_id)
   LEFT JOIN addresses a ON (a.entity_id=o.organization_id AND 
a.instance=".$_SESSION['instance'].")

   WHERE p.instance_id=".$_SESSION['instance']."
   AND m.instance_id=".$_SESSION['instance']."
   AND p.person_id = ".$_SESSION['person_id']."
   AND o.active='Y'
   AND (
   p.last_name LIKE 
'%".mysql_real_escape_string($person['last_name'])."%' OR
   o.email_address = 
'".mysql_real_escape_string($person['email_address'])."' OR
   p.email = 
'".mysql_real_escape_string($person['email'])."'

  ";
if (!empty($phone_home))
{
   $query .= "
   OR p.phone = '".$person['phone']."'";
}
if (!empty($person['phone']))
{
   $query .= "
   OR o.phone = '".$person['phone']."'";
}
if (!empty($person['org_name']))
{
   $query .= "
   OR o.full_name LIKE 
'%".mysql_real_escape_string($person['org_name'])."%'";

}

$query .= "
   )
   ORDER BY p.last_name ASC, p.first_name ASC ";


$myquery = mysql_query($query);
while($result = mysql_fetch_array($myquery))
{
   # I compare record with visitor's data and assign points to 
$RANK[$result['person_id']]
   # if there is at least one "match"  assign the record to an array 
$RECORDS['person_id']

}

then sort $RANK desc and then list sorted array $RANK on screen with 
matching $RECORDS elements.


It works but it could take 10-15 seconds to create the list if database 
has e.g. 10,000 records



anybody had the same or similar project? I'll appreciate any suggestion. 
how to setup database (mysql) and the best way to do the search code (php).


thanks for any help.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search functionality

2008-09-24 Thread Bastien Koert
On Wed, Sep 24, 2008 at 4:47 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:

>   Its pretty straight forward, you create a query that extracts the name
>>> and id of the records with a relevant where clause created on the fly. When
>>> outputing the data, each record gets created as a link that then loads
>>> another page/div with the total dataset for that record. The question for
>>> you is how you want the interface for the search to work. You can provide a
>>> dropdown with some choices (date, zip, etc) and a text input / date input
>>> picker to allow the user to enter the data. This then gets submitted and
>>> runs the query
>>
>>
>
> Correct, right now each record is displayed on the screen as a link.  When
> the link is clicked a query runs to pull all of the related data and
> displays it as a subset of items under the main link.
>
> The problem is, since I am not pulling all of the detail when I run the
> initial query, what would be the best way to find the search results when
> they will most liely be contained in the data I did not initially pull.
>
>
>
> Pass the search criteria previously entered thru session or hidden fields
or in the url along with the id to further refine the search


-- 

Bastien

Cat, the other other white meat


Re: [PHP] Search functionality

2008-09-24 Thread Dan Shirah
>
>   Its pretty straight forward, you create a query that extracts the name
>> and id of the records with a relevant where clause created on the fly. When
>> outputing the data, each record gets created as a link that then loads
>> another page/div with the total dataset for that record. The question for
>> you is how you want the interface for the search to work. You can provide a
>> dropdown with some choices (date, zip, etc) and a text input / date input
>> picker to allow the user to enter the data. This then gets submitted and
>> runs the query
>
>

Correct, right now each record is displayed on the screen as a link.  When
the link is clicked a query runs to pull all of the related data and
displays it as a subset of items under the main link.

The problem is, since I am not pulling all of the detail when I run the
initial query, what would be the best way to find the search results when
they will most liely be contained in the data I did not initially pull.


Re: [PHP] Search functionality

2008-09-22 Thread Bastien Koert
On Mon, Sep 22, 2008 at 4:07 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:

> Hello all,
>
> I'm looking for suggestions on how to create a search function within my
> application.  First I'll give you an overview.
>
> At the top of my page I have a form that contains name and date fields.
> When a user puts in some data and selects "Search" a simple column of
> results will be displayed on the left side of the screen.
>
> Example:
>
> User searchs for a date of "09/22/08" and a name of "Customers." In the
> left
> column a list of all customers for that day will be generated.  There is A
> LOT of detail associated with these customer results therefore all data
> such
> as name, address, zip code, order number etc is not pulled from the
> database
> upon initial search.  Instead, if a user clicks a customer name a seperate
> query will run and retrieve all of the pertinent data and provide a
> bulleted
> list under the customer name.
>
> What my vendor wants me to do is provide a way for someone to search
> through
> all the customers including the details that I do not initially display to
> allow them to find specific data.  Such as finiding a record with a
> specific
> zip code.  They then want to be able to click next to go to each
> consecutive
> record with that zip code.
>
> Any ideas on how to do this since all that data is not initially pulled in?
>

Its pretty straight forward, you create a query that extracts the name and
id of the records with a relevant where clause created on the fly. When
outputing the data, each record gets created as a link that then loads
another page/div with the total dataset for that record. The question for
you is how you want the interface for the search to work. You can provide a
dropdown with some choices (date, zip, etc) and a text input / date input
picker to allow the user to enter the data. This then gets submitted and
runs the query

 0 )
{
  while ($rows = mysql_fetch_array($result)){
echo "{$rows['cus_name']}";
  }

}else{
  echo "No results";
}

?>

or something like that
-- 

Bastien

Cat, the other other white meat


[PHP] Search functionality

2008-09-22 Thread Dan Shirah
Hello all,

I'm looking for suggestions on how to create a search function within my
application.  First I'll give you an overview.

At the top of my page I have a form that contains name and date fields.
When a user puts in some data and selects "Search" a simple column of
results will be displayed on the left side of the screen.

Example:

User searchs for a date of "09/22/08" and a name of "Customers." In the left
column a list of all customers for that day will be generated.  There is A
LOT of detail associated with these customer results therefore all data such
as name, address, zip code, order number etc is not pulled from the database
upon initial search.  Instead, if a user clicks a customer name a seperate
query will run and retrieve all of the pertinent data and provide a bulleted
list under the customer name.

What my vendor wants me to do is provide a way for someone to search through
all the customers including the details that I do not initially display to
allow them to find specific data.  Such as finiding a record with a specific
zip code.  They then want to be able to click next to go to each consecutive
record with that zip code.

Any ideas on how to do this since all that data is not initially pulled in?


Re: [PHP] Search Suggestions

2008-08-31 Thread Jochem Maas

Dan Shirah schreef:

Hello,

I'm hoping to get a few good ideas on the best way to perform a search of
PHP results.

Currently I have a page that returns a list of collapsed customer data:

Example
+ John Smith
+ Jane Doe
+ Robert Jones
+ Dale Bennett

If the user clicks on a customer name it will expand the selection:

Example
 - John Smith
  - 123 Anywhere Street
  - myCity
  - myState
  - myZipcode
  - myWebsite
+ Jane Doe
+ Robert Jones
+ Dale Bennett

Now, what my client wants is a Search functionality that will allow him to
type in myState and have the application automatically expand and focus on
the first match. Then, be able to click "Next" and have it collapse the
first result and expand the next result that contains the same state.

Any ideas?
I was thinking that maybe I would have to create a temp table so it could be
searched against, but I'm not sure if that is the best idea.  Also, in order
to save processing time, the way I made the above expanding/collapsing list
is I don't not pull in the customer details intially but instead run a query
and get the details when the name is clicked for expansion.  This is because
there could be potentially 1,000's of result and getting all of the names
and all of the details at page load would 1) take longer than a user is
willing to wait 2) exceed the timeout 3) exceed the memory allocation


I would think about caching data to streamline searching ... it would
be very helpful if your address data was normalized when possible (e.g.
states are related to users based on a database id rather than being
loose bits of text) .. so that you can precalculate (e.g. via a cronjob) user 
ids
that 'match' against certain strings) ... where you stick your cache is upto
you.

I would also cache the structured data for each user so that you can
very quickly output (e.g. via JSON) the data for a given user/users
to the browser.

And then the fun part: build an ajaxy wotsit that paginates, sorts, searches
and highlights the data ... and then couple it to server scripts that
use the precalculated data to cough up matching users id (for searches) and
userdata (for display).

most of the hardwork will be in building the client side magic, the
scripts that act as an interface on the precalculated data will be simple,
and the precalculation routines shouldn't be to hairy (although you'll have
to think careful about how to cover all your angles when it comes to the
kind of data that can be search through)


Thanks for any help/ideas.


I'm interested to know if my brainfart made any sense to you :-)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search Suggestions

2008-08-27 Thread tedd

At 9:31 AM -0400 8/26/08, Dan Shirah wrote:

Any ideas?


Dan:

Yes, a few of them.

1. Use LIMIT in your MySQL query to get the number of records 
provided down to a manageable size.


2. Use pagination to keep the page size to a manageable size.

Here's an example:

http://php1.net/b/pagination-images/

Here's an example with code and it has an example of using LIMIT with offsets:

http://webbytedd.com/bbb/paging/

3. Then use a toggle for showing small/large amount of information.

http://webbytedd.com/cc/toggle/

I often use this for showing clients lot's of data without having to 
show all of it at one time. Here's another example:


http://sperling.com/quarters/

Note how "The rules" and "How to win" are shown.

As to showing the user one item expanded and all the rest collapsed, 
I leave that to you, but my hint is redefining the css display rule 
(display: block) on the initial load of the page.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Search Suggestions

2008-08-26 Thread Simcha Younger

You could have (and I assume you already have) an id for each
customer_name-DIV . This id should correspond to the customer id in your DB.
You can then send out an AJAX request with the search term and have it
return a list of the ids of the customer-DIV's to expand.
A similar solution is to send back a list of names to expand, and then have
Javascript go through the whole listing to find those names.

Simcha Younger


-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 26, 2008 3:31 PM
To: PHP-General List
Subject: [PHP] Search Suggestions

Hello,

I'm hoping to get a few good ideas on the best way to perform a search of
PHP results.

Currently I have a page that returns a list of collapsed customer data:

Example
+ John Smith
+ Jane Doe
+ Robert Jones
+ Dale Bennett

If the user clicks on a customer name it will expand the selection:

Example
 - John Smith
  - 123 Anywhere Street
  - myCity
  - myState
  - myZipcode
  - myWebsite
+ Jane Doe
+ Robert Jones
+ Dale Bennett

Now, what my client wants is a Search functionality that will allow him to
type in myState and have the application automatically expand and focus on
the first match. Then, be able to click "Next" and have it collapse the
first result and expand the next result that contains the same state.

Any ideas?

I was thinking that maybe I would have to create a temp table so it could be
searched against, but I'm not sure if that is the best idea.  Also, in order
to save processing time, the way I made the above expanding/collapsing list
is I don't not pull in the customer details intially but instead run a query
and get the details when the name is clicked for expansion.  This is because
there could be potentially 1,000's of result and getting all of the names
and all of the details at page load would 1) take longer than a user is
willing to wait 2) exceed the timeout 3) exceed the memory allocation

Thanks for any help/ideas.

Dan

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.6.7/1632 - Release Date: 25/08/2008
07:05


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search Suggestions

2008-08-26 Thread Dan Shirah
Hello,

I'm hoping to get a few good ideas on the best way to perform a search of
PHP results.

Currently I have a page that returns a list of collapsed customer data:

Example
+ John Smith
+ Jane Doe
+ Robert Jones
+ Dale Bennett

If the user clicks on a customer name it will expand the selection:

Example
 - John Smith
  - 123 Anywhere Street
  - myCity
  - myState
  - myZipcode
  - myWebsite
+ Jane Doe
+ Robert Jones
+ Dale Bennett

Now, what my client wants is a Search functionality that will allow him to
type in myState and have the application automatically expand and focus on
the first match. Then, be able to click "Next" and have it collapse the
first result and expand the next result that contains the same state.

Any ideas?

I was thinking that maybe I would have to create a temp table so it could be
searched against, but I'm not sure if that is the best idea.  Also, in order
to save processing time, the way I made the above expanding/collapsing list
is I don't not pull in the customer details intially but instead run a query
and get the details when the name is clicked for expansion.  This is because
there could be potentially 1,000's of result and getting all of the names
and all of the details at page load would 1) take longer than a user is
willing to wait 2) exceed the timeout 3) exceed the memory allocation

Thanks for any help/ideas.

Dan


Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

http://framework.zend.com/manual/en/zend.search.lucene.html


Nice one, thanks.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Eric Butera
On Sat, Jul 19, 2008 at 4:06 PM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> Hi,
>
>> I've been playing around with the zend search lucene and it is really
>> powerful too.
>
> Worth looking into?
>
> --
> Richard Heyes

Most definitely.  But with all that power and optional stuff comes
complexity too.  It isn't a five minute attempt to see something
working.  In fact I thought it was a bit harder than it needed to be
getting it working (specifically removing a document/re-adding to
update).

What I've done is get a really basic add/edit/remove & search on
partial content set up.  It is pretty easy to set up a search on a
site with it now.  From there I can move from a timed cron job
re-indexing to actual real time updates on content saving if needed.
Also you can customize what exactly gets stored in the search database
too.  You can specify you want to search on document titles versus
just the whole content.  There is a lot there to play with.

Before this I used either a fulltext, simple LIKE, or an external
program like Swish-e.  I really enjoyed using Swish-e, except it
doesn't support utf-8 which is silly in 2008.

http://framework.zend.com/manual/en/zend.search.lucene.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Hi,


I've been playing around with the zend search lucene and it is really
powerful too.


Worth looking into?

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

> the entire King James Bible in a dB -- interesting read

That's debateable... :-)

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Eric Butera
On Sat, Jul 19, 2008 at 3:40 PM, tedd <[EMAIL PROTECTED]> wrote:
> At 1:56 PM -0400 7/19/08, Eric Butera wrote:
>>
>>
>> Ever play with fulltext search?
>
>
> Never in public. :-)
>
> You could throw all text into your database and then do a fulltext search to
> give back the related pages -- that would work. I think I saw that as an
> example in one of the books I read. PHP Cookbook shows an example of the
> entire King James Bible in a dB -- interesting read and demo.
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Yea I've done a lot of "compiling" content and then searching against
what it is supposed to be.  Fulltext works really well for things like
that.

I've been playing around with the zend search lucene and it is really
powerful too.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread tedd

At 1:56 PM -0400 7/19/08, Eric Butera wrote:



Ever play with fulltext search?



Never in public. :-)

You could throw all text into your database and then do a fulltext 
search to give back the related pages -- that would work. I think I 
saw that as an example in one of the books I read. PHP Cookbook shows 
an example of the entire King James Bible in a dB -- interesting read 
and demo.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Ever play with fulltext search?


Yes, though it's not suitable in this instance.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Eric Butera
On Sat, Jul 19, 2008 at 5:47 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> Hey,
>
> I was hoping to get some ideas on improving a sites search. Currently I have
> two - not a lot but I've been thinking about this for a few minutes.
>
> Currently the site in question uses a very basic LIKE in MySQL, eg %blah%,
> but naturally this finds terms such as hjkblahbjkk - which is not desired.
> Or such matches should be ranked lower than something that matches the exact
> word blah. My thoughts are using a points system, eg assigning 5 points for
> an exact word match, 1 for a partial match. And then ordering the search
> results by the total points assigned.
>
> Either that or using external search code and not worrying so much.
>
> Cheers.
>
> --
> Richard Heyes
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Ever play with fulltext search?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Mark Kelly
Hi.

Just noticed I replied direct rather than to the list last time, sorry 
about that.

On Saturday 19 July 2008, Richard Heyes wrote:
> How much traffic do you have and what's your hardware? Are your queries
> cached and subsequently repeated? Do you pre cache common queries?

I've done this kind of search twice, but both were for internal web apps so 
I can't link you to them. In both cases I return only items IDs and limit 
it to 10 results, with the subsequent queries being done only if the 
previous ones didn't return enough results to fill the page. Both of these 
speed it up a lot, obviously. One of them has a possible max of 6 
different ways to examine the data tables, and still return a full results 
page in under half a second.

Nothing is pre-cached, and I'm really not sure about the hardware, sorry, 
that's the IT guy's problem. I don't imagine it's anything spectacular 
though.

The apps get quite heavy use but I'm with Tedd on the results issue, we 
only see maybe 10% of the users going to page 2, but these are internal 
users searching company data, so the pattern may not be typical.

Hope you find something you're happy with,

Mark

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes
I'm sure that would work, but just how many LIKE items do you want to 
show the user? For me, I would rather not show them anything if there is 
nothing on my site that matches their exact search criteria.


Certainly an idea, but something like "We also found..." might be 
helpful in regard to typos.


The point being, from my perspective, users don't spend a lot of time 
reading results. They want answers quick and short. I would think that 
if you provided them with a long list of "Did you mean this?" results -- 
that might frustrate the user.


A good point. For example I rarely go further than the first page on 
Google (I never need to really, but whatever...).


> if someone could come up with a

better way, I am sure you could.


Thanks for the vote of confidence, but I've kept away from search as it 
doesn't overly interest me. In fact that's quite an over statement. It 
really bores the pants off me.


But, the point is, would it make a 
difference?


Well spending some time on it will improve it as it's just the basic 
LIKE at the moment, but point taken - I really don't want to spend a lot 
of time on it.


--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread tedd

At 10:47 AM +0100 7/19/08, Richard Heyes wrote:

Hey,

I was hoping to get some ideas on improving a sites search. 
Currently I have two - not a lot but I've been thinking about this 
for a few minutes.


That'll leave a mark. :-)

Currently the site in question uses a very basic LIKE in MySQL, eg 
%blah%, but naturally this finds terms such as hjkblahbjkk - which 
is not desired. Or such matches should be ranked lower than 
something that matches the exact word blah. My thoughts are using a 
points system, eg assigning 5 points for an exact word match, 1 for 
a partial match. And then ordering the search results by the total 
points assigned.


I'm sure that would work, but just how many LIKE items do you want to 
show the user? For me, I would rather not show them anything if there 
is nothing on my site that matches their exact search criteria.


The point being, from my perspective, users don't spend a lot of time 
reading results. They want answers quick and short. I would think 
that if you provided them with a long list of "Did you mean this?" 
results -- that might frustrate the user.


If I did that, then I would also highlight each LIKE search word to 
show the user why the LIKE results were being presented to them.



Either that or using external search code and not worrying so much.


Considering all, using an external search would probably be better -- 
less time worrying about it and delivering good results to users 
queries is not as simple as it seems. However, if someone could come 
up with a better way, I am sure you could. But, the point is, would 
it make a difference?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Mark Kelly wrote:

Hi.

On Saturday 19 July 2008, Richard Heyes wrote:

Currently the site in question uses a very basic LIKE in MySQL, eg
%blah%, but naturally this finds terms such as hjkblahbjkk - which is
not desired. Or such matches should be ranked lower than something that
matches the exact word blah.


I did this with 2 queries, and no need for messing with points etc (unless 
you particularly want to). 

Start with "LIKE 'word'" query and pull the results into a results array. 
Then do the same query but with "LIKE '%word%'" and loop through append 
the results to the results array. Use something like "if 
(!in_array($thisResult,$resultSet))" while appending to avoid duplicates.


Well no. LIKE is slow and so is in_array(). Admittedly it's not a busy 
site, but still.



How much traffic do you have and what's your hardware? Are your queries 
cached and subsequently repeated? Do you pre cache common queries?


Cheers.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Hey,

I was hoping to get some ideas on improving a sites search. Currently I 
have two - not a lot but I've been thinking about this for a few minutes.


Currently the site in question uses a very basic LIKE in MySQL, eg 
%blah%, but naturally this finds terms such as hjkblahbjkk - which is 
not desired. Or such matches should be ranked lower than something that 
matches the exact word blah. My thoughts are using a points system, eg 
assigning 5 points for an exact word match, 1 for a partial match. And 
then ordering the search results by the total points assigned.


Either that or using external search code and not worrying so much.

Cheers.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search like php.net's URL thingy

2008-06-05 Thread Ryan S
Hey!

Thanks for replying.

Digging a bit more i found 


RewriteEngine On
RewriteRule ^([a-z][0-9][A-Z][aA0-zZ0])$ jj.php?show=$1


But it does not work :( do you see any fault with the above?

Thanks!
R


 --
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



- Original Message 
From: Bernhard Kohl <[EMAIL PROTECTED]>
To: Ryan S <[EMAIL PROTECTED]>
Sent: Thursday, June 5, 2008 9:25:46 PM
Subject: Re: [PHP] Search like php.net's URL thingy

you should familiarize yourself with the rewrite module of the apache server 
(if u operate on that one)

it's pretty much the same as regular expressions syntax

example:

i want all requests going to www.example.com/test being forwarded to 
index.php?a=test

place following into your .htaccess file in the root directory:

RewriteEngine on
RewriteBase /

RewriteRule ^([a-zA-Z])$ index.php?a=$1

the whole thing can get pretty complex with alot of rewrite conditions and 
stuff.

good luck


On 6/5/08, Ryan S <[EMAIL PROTECTED]> wrote:
Hey,
one of the things that make the php.net site so cool is how easy it is to find 
info for a function or a list of topics.. eg:

http://php.net/arrays
http://php.net/count

I'm sure nearly all of you reading this have done it more times than you would 
care to count, i'm trying to get something like this on my own site but even 
after going to php.net and clicking on the view source buttons am a bit 
confused.

basically this is what i am trying, people who type in 
http://www.mysite.com/asdf
should not be shown a 404 not found page but instead "asdf" should be passed 
onto my script where i can do a search on the term and either give them back 
the results of that search or direct them to a custom 404 page.

since i couldnt find the answer via php.net's source i started messing around 
with how i *think* its done... tell me if i am on the correct track: when 
someone requests a page that does not exist, a .htaccess file them up and also 
takes the page name they were searching for and redirects them to a script...

So far i have only been able to get the .htaccess file point to my custom 404 
page... but how do i get it to pass the parameter of the not-found-page to my 
script?

Would appreciate any code, tips, urls you can give me.

Thanks!
Ryan



  --
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  

Re: [PHP] Search like php.net's URL thingy

2008-06-05 Thread Daniel Brown
On Thu, Jun 5, 2008 at 3:07 PM, Ryan S <[EMAIL PROTECTED]> wrote:
> Hey,
> one of the things that make the php.net site so cool is how easy it is to 
> find info for a function or a list of topics.. eg:
>
> http://php.net/arrays
> http://php.net/count
>
[snip!]
>
> since i couldnt find the answer via php.net's source i started messing around 
> with how i *think* its done... tell me if i am on the correct track: when 
> someone requests a page that does not exist, a .htaccess file them up and 
> also takes the page name they were searching for and redirects them to a 
> script...

You're on the right track, Ryan.

Look up mod_rewrite for Apache, and also consider that php.net
uses operations similar to (though not exactlt like) the following
procedure:

#.htaccess
Redirect /ciel http://php.net/manual/en/function.ceil.php


-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search like php.net's URL thingy

2008-06-05 Thread Ryan S
Hey,
one of the things that make the php.net site so cool is how easy it is to find 
info for a function or a list of topics.. eg:

http://php.net/arrays
http://php.net/count

I'm sure nearly all of you reading this have done it more times than you would 
care to count, i'm trying to get something like this on my own site but even 
after going to php.net and clicking on the view source buttons am a bit 
confused.

basically this is what i am trying, people who type in 
http://www.mysite.com/asdf
should not be shown a 404 not found page but instead "asdf" should be passed 
onto my script where i can do a search on the term and either give them back 
the results of that search or direct them to a custom 404 page.

since i couldnt find the answer via php.net's source i started messing around 
with how i *think* its done... tell me if i am on the correct track: when 
someone requests a page that does not exist, a .htaccess file them up and also 
takes the page name they were searching for and redirects them to a script... 

So far i have only been able to get the .htaccess file point to my custom 404 
page... but how do i get it to pass the parameter of the not-found-page to my 
script?

Would appreciate any code, tips, urls you can give me.

Thanks!
Ryan



 --
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



  

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search engines and cookies

2008-04-07 Thread tedd

At 3:29 PM +0200 4/7/08, Emil Edeholt wrote:

Hi,

Do you guys how search engines like cookies? One site I'm working on 
now requires the user to select which region he/she is from on the 
start page. That value is stored in a cookie. So without cookies you 
can't get past the start page. Does this leave the search engines at 
the start page? Right now google only index the start pages on my 
site and I'm trying to figure out why.


If I can't use cookies, how would you force users to select a region 
but letting the search engine spiders in on the site somehow?


Hope this wasn't too off topic.

Kind Regards Emil


Emil:

My advice -- give the SE what it's looking for. Place a description 
of what your site is about on the start page. If you don't want users 
to see it, then place the text off-left via css position. This would 
also help those with assistive technologies and thus SE's shouldn't 
complain.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search engines and cookies

2008-04-07 Thread Evert Lammerts
Search engines won't come past that page. How about setting a default 
region when a user enters a different page then your main page?


Daniel Brown wrote:

On Mon, Apr 7, 2008 at 9:29 AM, Emil Edeholt <[EMAIL PROTECTED]> wrote:
  

Hi,

 Do you guys how search engines like cookies? One site I'm working on now
requires the user to select which region he/she is from on the start page.
That value is stored in a cookie. So without cookies you can't get past the
start page. Does this leave the search engines at the start page? Right now
google only index the start pages on my site and I'm trying to figure out
why.

 If I can't use cookies, how would you force users to select a region but
letting the search engine spiders in on the site somehow?



One way to do it would be to allow Google (and/or other search
engines) to access the site by bypassing the region-selection
entirely.



  



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search engines and cookies

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 9:29 AM, Emil Edeholt <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  Do you guys how search engines like cookies? One site I'm working on now
> requires the user to select which region he/she is from on the start page.
> That value is stored in a cookie. So without cookies you can't get past the
> start page. Does this leave the search engines at the start page? Right now
> google only index the start pages on my site and I'm trying to figure out
> why.
>
>  If I can't use cookies, how would you force users to select a region but
> letting the search engine spiders in on the site somehow?

One way to do it would be to allow Google (and/or other search
engines) to access the site by bypassing the region-selection
entirely.



-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search engines and cookies

2008-04-07 Thread Emil Edeholt

Hi,

Do you guys how search engines like cookies? One site I'm working on now 
requires the user to select which region he/she is from on the start 
page. That value is stored in a cookie. So without cookies you can't get 
past the start page. Does this leave the search engines at the start 
page? Right now google only index the start pages on my site and I'm 
trying to figure out why.


If I can't use cookies, how would you force users to select a region but 
letting the search engine spiders in on the site somehow?


Hope this wasn't too off topic.

Kind Regards Emil

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search function not working...

2008-02-01 Thread Jim Lucas

Jason Pruim wrote:
So I said in another thread that I would be asking another question 
about functions... So here it goes, I am attempting to write a function 
to search the database, which used to work just fine when I wrote it 
without using a function (Would that be considered static?) Now that I 
am attempting to rewrite my stuff so I can reuse the code, now it's not 
working... Here is what I used to do and it worked just fine:



$qstring = "SELECT * FROM ".$table." WHERE FName like '%$search%' or 
LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search%' 
or City like '%$search%' or State like '%$search%' or Zip like 
'%$search%' or XCode like '%$search%'";

if ($_SESSION['search'] != NULL){
echo "The search string is: $search.";
$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
//display search form
echo "

Search:



";



echo <<
Return to database
Total Records found: {$num_rows}
Export selection to excel



First Name
Last Name
Address Line 1
Address Line 2
City
State
Zip
Code
ID #
Edit
Delete

   
HTML;

echo "Just testing: ".$_SESSION['search'];
while($qrow = mysql_fetch_assoc($qresult)) {
//Display the search results using heredoc syntax
echo <<

   
{$qrow['FName']}

{$qrow['LName']}
{$qrow['Add1']}
{$qrow['Add2']}
{$qrow['City']}
{$qrow['State']}
{$qrow['Zip']}
{$qrow['XCode']}
{$qrow['Record']}
Edit
Delete




HTML;

Now, here is what I have as a function and is not working:

function search($searchvar, $table, $num_rows, $FName, $LName, 
$Add1, $Add2) {
$qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%' 
or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like 
'%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' 
or Zip like '%$searchvar%' or XCode like '%$searchvar%'";

$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
//while($qrow = mysql_fetch_assoc($qresult)) {   
   
$FName = $qrow['FName'];

$LName = $qrow['LName'];
$Add1 = $qrow['Add1'];
$Add2 = $qrow['Add2'];



return;

}

?>


And what happens, is first of all it displays the entire database on the 
search page, which I'm kind of okay with... But when you search, it 
updates the variables, and echo's out the right search term, but it 
doesn't update the database to only show the search results... I think 
it might be tied to it displaying the entire database at page load... 
But I'm not sure.. Anyone have an idea of what I did wrong other then 
everything? :)



Oh, and as far as calling the function I do this: search($searchvar, 
$table, $num_rows, $FName, $LName, $Add1, $Add2);




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





Ok, here would be my rendition of this function.

 0 ) {

// Loop through result set
while ( $row = mysql_fetch_assoc($res) ) {

// Place returned row of data into our results array
$results[] = $row;

}

}

// Return result set of data, or blank array
return $results;

}


// $_SESSION['search'] = $_GET['search'];
$searchvar = 'something you want to search for';

// Call function
$dataSet = search($searchvar, 'myTable');

// Get the number of results returned
$num_rows = count($dataSet);

?>

if the above code get messed up by the email, check out this link.

http://www.cmsws.com/examples/php/testscripts/[EMAIL 
PROTECTED]/Search_function_not_working.php

This should return to you all the information you need.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search function not working...

2008-02-01 Thread David Giragosian
>
>  Jason,
>
> Untested, but try this...
>
> function search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
> $Add2) {
>$qstring = "SELECT * FROM ".$table." WHERE FName like
> '%$searchvar%'
> or LName like '%$searchvar%' or Add1 like
> '%$searchvar%' or Add2 like
> '%$searchvar%' or City like '%$searchvar%' or
> State like '%$searchvar%'
> or Zip like '%$searchvar%' or XCode like
> '%$searchvar%'";
>
> $qrow = mysql_query($qstring) or die(mysql_error());
> $qresult = $qrow;
> $num_rows = mysql_num_rows($qresult);
>
>$outputStr = "";
>
> while($qrow = mysql_fetch_assoc($qresult)) {
>$FName = $qrow['FName'];
>$LName = $qrow['LName'];
>$Add1 = $qrow['Add1'];
>$Add2 = $qrow['Add2'];
>
>$outputStr .=
> "$FName$LName$ADD1$ADD2\n";
>
> }
>
> $outputStr .= "";
>
>
> return $outputStr;
>
> }
>
> $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName,
> $Add1, $Add2);
>
> echo $searchReturn;
>
> David
>

Hold on a moment...

function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2)
{
   $qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like
'%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State
like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like
'%$searchvar%'";

$qresult = mysql_query($qstring) or die(mysql_error());

//$qresult = $qrow; // this line is the problem !

$num_rows = mysql_num_rows($qresult);

   $outputStr = "";

while($qrow = mysql_fetch_assoc($qresult)) {
   $FName = $qrow['FName'];
   $LName = $qrow['LName'];
   $Add1 = $qrow['Add1'];
   $Add2 = $qrow['Add2'];

   $outputStr .=
"$FName$LName$ADD1$ADD2\n";

}

$outputStr .= "";


return $outputStr;

}

$searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
$Add2);

echo $searchReturn;

That should work, assuming the query returns at least one row..

David


Re: [PHP] Search function not working...

2008-02-01 Thread David Giragosian
On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:

>
>  On Feb 1, 2008, at 2:20 PM, David Giragosian wrote:
>
>  On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
> >
> > [snip long explanation of problem]
>
>
>  function search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
> $Add2) {
>$qstring = "SELECT * FROM ".$table." WHERE FName like
> '%$searchvar%'
> or LName like '%$searchvar%' or Add1 like
> '%$searchvar%' or Add2 like
> '%$searchvar%' or City like '%$searchvar%' or
> State like '%$searchvar%'
> or Zip like '%$searchvar%' or XCode like
> '%$searchvar%'";
>
> $qrow[]= mysql_query($qstring) or die(mysql_error());
> $qresult = $qrow[0];
> $num_rows = mysql_num_rows($qresult);
> while($qrow = mysql_fetch_assoc($qresult)) {
>$FName = $qrow['FName'];
>$LName = $qrow['LName'];
>$Add1 = $qrow['Add1'];
>$Add2 = $qrow['Add2'];
>
> }
>
> // what do you want to return...?
> return;
>
> }
>
> ?>
>
> $returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName,
> $Add1, $Add2);
>
> Jason,
>
> 1. You're missing a closing brace at the end of the while loop.
> 2. You're not returning anything from the function.
>
> The input parameters are pretty clear but what were you expecting to
> accomplish within the function?
>
> All the data returned from the query only have scope within the function,
> so unless you return something, like an array or a string, use references,
> or write to a global variable, you're not doing anything with the data from
> the db.
>
> David
>
>
> Hi David,
>
>
> Thanks for looking. I'm just starting to learn about functions, and
> obviously making a few mistakes along the road...
>
>
> Basically what I am trying to do is allow my customer the ability to
> search the database, display it on the website, and then export it to excel
> if they wish...
>
>
> the missing closing brace was a bad copy/paste job.
>
>
> I have tried to add $searchReturn = search($searchvar, $table, $num_rows,
> $FName, $LName, $Add1, $Add2);
> and then do a vardump on it and it's not returning any thing.
>
>
> I've also changed the return line to return $searchReturn['FName'];
> but it's still not showing through...
>
>
> I think functions will be the death of me... at least until I understand
> how to use them :)
>
>
> I think I'm off to google some more and see if I can get any more info...
>
>
> Thanks again for your help!
>


Jason,

Untested, but try this...

function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2)
{
   $qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like
'%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State
like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like
'%$searchvar%'";

$qrow = mysql_query($qstring) or die(mysql_error());
$qresult = $qrow;
$num_rows = mysql_num_rows($qresult);

   $outputStr = "";

while($qrow = mysql_fetch_assoc($qresult)) {
   $FName = $qrow['FName'];
   $LName = $qrow['LName'];
   $Add1 = $qrow['Add1'];
   $Add2 = $qrow['Add2'];

   $outputStr .=
"$FName$LName$ADD1$ADD2\n";

}

$outputStr .= "";


return $outputStr;

}

$searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
$Add2);

echo $searchReturn;

David


Re: [PHP] Search function not working...

2008-02-01 Thread Jason Pruim


On Feb 1, 2008, at 2:20 PM, David Giragosian wrote:


On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
[snip long explanation of problem]


function search($searchvar, $table, $num_rows, $FName, $LName,  
$Add1, $Add2) {
   $qstring = "SELECT * FROM ".$table." WHERE FName like '% 
$searchvar%'
or LName like '%$searchvar%' or Add1 like '% 
$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%'  
or State like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like '% 
$searchvar%'";


$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
while($qrow = mysql_fetch_assoc($qresult)) {
   $FName = $qrow['FName'];
   $LName = $qrow['LName'];
   $Add1 = $qrow['Add1'];
   $Add2 = $qrow['Add2'];

}

// what do you want to return...?
return;

}

?>

$returnedSomething = search($searchvar, $table, $num_rows, $FName,  
$LName, $Add1, $Add2);


Jason,

1. You're missing a closing brace at the end of the while loop.
2. You're not returning anything from the function.

The input parameters are pretty clear but what were you expecting to  
accomplish within the function?


All the data returned from the query only have scope within the  
function, so unless you return something, like an array or a string,  
use references, or write to a global variable, you're not doing  
anything with the data from the db.


David


Hi David,

Thanks for looking. I'm just starting to learn about functions, and  
obviously making a few mistakes along the road...


Basically what I am trying to do is allow my customer the ability to  
search the database, display it on the website, and then export it to  
excel if they wish...


the missing closing brace was a bad copy/paste job.

I have tried to add $searchReturn = search($searchvar, $table,  
$num_rows, $FName, $LName, $Add1, $Add2);

and then do a vardump on it and it's not returning any thing.

I've also changed the return line to return $searchReturn['FName'];
but it's still not showing through...

I think functions will be the death of me... at least until I  
understand how to use them :)


I think I'm off to google some more and see if I can get any more  
info...


Thanks again for your help!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] Search function not working...

2008-02-01 Thread David Giragosian
On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> So I said in another thread that I would be asking another question
> about functions... So here it goes, I am attempting to write a
> function to search the database, which used to work just fine when I
> wrote it without using a function (Would that be considered static?)
> Now that I am attempting to rewrite my stuff so I can reuse the code,
> now it's not working... Here is what I used to do and it worked just
> fine:
>
>
> $qstring = "SELECT * FROM ".$table." WHERE FName like '%$search%' or
> LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search
> %' or City like '%$search%' or State like '%$search%' or Zip like '%
> $search%' or XCode like '%$search%'";
> if ($_SESSION['search'] != NULL){
>echo "The search string is: $search.";
>$qrow[]= mysql_query($qstring) or die(mysql_error());
>$qresult = $qrow[0];
>$num_rows = mysql_num_rows($qresult);
>//display search form
>echo "
>
>Search:
>
>
>
>";
>
>
>
> echo <Total Records found: {$num_rows}
>Export selection to excel
>
>
>
>First Name
>Last Name
>Address Line 1
>Address Line 2
>City
>State
>Zip
>Code
>ID #
>Edit
>Delete
>
>
> HTML;
>echo "Just testing: ".$_SESSION['search'];
> while($qrow = mysql_fetch_assoc($qresult)) {
>//Display the search results using heredoc syntax
> echo <<
>
>
>{$qrow['FName']}
>{$qrow['LName']}
>{$qrow['Add1']}
>{$qrow['Add2']}
>{$qrow['City']}
>{$qrow['State']}
>{$qrow['Zip']}
>{$qrow['XCode']}
>{$qrow['Record']}
>Edit
>Delete
>
>
>
> HTML;
>
> Now, here is what I have as a function and is not working:
>
>  $FName ="";
> $LName ="";
> $Add1 = "";
> $Add2 = "";
> //  $_SESSION['search'] = $_GET['search'];
>


function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2)
{
   $qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like
'%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State
like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like
'%$searchvar%'";

$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
while($qrow = mysql_fetch_assoc($qresult)) {
   $FName = $qrow['FName'];
   $LName = $qrow['LName'];
   $Add1 = $qrow['Add1'];
   $Add2 = $qrow['Add2'];

}

// what do you want to return...?
return;

}

?>

$returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName,
$Add1, $Add2);

Jason,

1. You're missing a closing brace at the end of the while loop.
2. You're not returning anything from the function.

The input parameters are pretty clear but what were you expecting to
accomplish within the function?

All the data returned from the query only have scope within the function, so
unless you return something, like an array or a string, use references, or
write to a global variable, you're not doing anything with the data from the
db.

David


[PHP] Search function not working...

2008-02-01 Thread Jason Pruim
So I said in another thread that I would be asking another question  
about functions... So here it goes, I am attempting to write a  
function to search the database, which used to work just fine when I  
wrote it without using a function (Would that be considered static?)  
Now that I am attempting to rewrite my stuff so I can reuse the code,  
now it's not working... Here is what I used to do and it worked just  
fine:



$qstring = "SELECT * FROM ".$table." WHERE FName like '%$search%' or  
LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search 
%' or City like '%$search%' or State like '%$search%' or Zip like '% 
$search%' or XCode like '%$search%'";

if ($_SESSION['search'] != NULL){
echo "The search string is: $search.";
$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
//display search form
echo "

Search:



";



echo <

And what happens, is first of all it displays the entire database on  
the search page, which I'm kind of okay with... But when you search,  
it updates the variables, and echo's out the right search term, but it  
doesn't update the database to only show the search results... I think  
it might be tied to it displaying the entire database at page load...  
But I'm not sure.. Anyone have an idea of what I did wrong other then  
everything? :)



Oh, and as far as calling the function I do this: search($searchvar,  
$table, $num_rows, $FName, $LName, $Add1, $Add2);




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread Jim Lucas

dwa wrote:

Hello people,
i have a question??

I have an application written in c++ and this throw real time data as 
udp-pakets all the time (interval 1 min and values in a wrapper like an 
own protocol are floats and longs).


Is there any possibility to catch the udp packets - parse the pakets und 
show the values in tables in a html-doc in real time???


What technologies are good? ajax? cgi? ive no idea!

mfg
david


I recently built a PHP daemon.  It uses sockets to listen on a given port for 
UDP packets.

Take in a request, processes, decides what it needs to do based off the request and then takes 
action.  Once it is done with said action, starts listening again.  This process is done a few times 
a second.  I have it logging connections to a DB and saving other information to a log file in the 
file system.


You could easily take something like this and create a daemon that would listen for incoming 
connections and from the data it gets build a page and drop that onto the file system.


here is an example of what I do

if ( $socket = @stream_socket_server('udp://'.LISTEN_IP.':'.LISTEN_PORT, $errno, $errstr, 
STREAM_SERVER_BIND) ) {

while ( true ) {
$packet = '';
while ( $buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, 
$remote_ip) ) {
$packet .= $buff;
}

//  if need be, loop this until you get to the end of your 
packet/information
while ( !empty($buff) ) {
$buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, 
$remote_ip);
}
//  work with $buff here to capture all your data.
//  Then also figure out when and if you need to exit

}
fclose($socket);
}

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread shiplu
On 8/28/07, Gevorg Harutyunyan <[EMAIL PROTECTED]> wrote:
>
> Barev David,
>
> I think this is solution
>
> 1. C/C++ updates database (MySQL or other)
> 2. There is some PHP file that is viewing your DB info(printing static
> info)
> 3. There is other PHP file that is using AJAX for interactive update of
> information (This one is sending request to first PHP file and if needed
> updating second one)
>
> I don't know maybe this is very complex, but I would choose this one ;)
>
> Best,
> Gevorg
>
> -Original Message-
> From: David Giragosian [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 28, 2007 10:08 PM
> To: Simon
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] c++ and php! search for a brigde
>
> On 8/28/07, Simon <[EMAIL PROTECTED]> wrote:
> >
> > you can use sockets in php, they work the same as berkley sockets
> > you can use system() in php, to call your C++ program (the program
> > could output html)
> > in my opinon CGI with C/C++ is obsolete, use php/apache for best
> results!
> >
> > another nice way is to have your C++ program independent, outputs its
> > results/values into a database (mysql)... and a php page will just
> > read what's in the database to display it nicely.
>
>
> That's what we do here. C/C++ app gathers and inserts the data into the
> db,
> minute by minute, and PHP apps are used for display, reports, graphics,
> etc... Our LAMP system has had nary a glitch in over 3 years of continuous
> usage.
>
> That would be a clean way of doing it.
> >
> > Good luck!
>
>
>
> David
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
No, this is not that tough. we did it before.

1. A C program retrieves data from several (more than 100) servers.
2. It saves the data in the MySQL db.
3. A php page is loaded with an ajax enabled
4. then a ajax call is sent to the same php file. it uses the setTimeout
function.
5. Data comes in json format.
6. data is formated by javascript and shown in the page.

Thats it.

-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time


RE: [PHP] c++ and php! search for a brigde

2007-08-28 Thread Gevorg Harutyunyan
Barev David,

I think this is solution

1. C/C++ updates database (MySQL or other)
2. There is some PHP file that is viewing your DB info(printing static info)
3. There is other PHP file that is using AJAX for interactive update of
information (This one is sending request to first PHP file and if needed
updating second one)

I don't know maybe this is very complex, but I would choose this one ;)

Best,
Gevorg

-Original Message-
From: David Giragosian [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 28, 2007 10:08 PM
To: Simon
Cc: php-general@lists.php.net
Subject: Re: [PHP] c++ and php! search for a brigde

On 8/28/07, Simon <[EMAIL PROTECTED]> wrote:
>
> you can use sockets in php, they work the same as berkley sockets
> you can use system() in php, to call your C++ program (the program
> could output html)
> in my opinon CGI with C/C++ is obsolete, use php/apache for best results!
>
> another nice way is to have your C++ program independent, outputs its
> results/values into a database (mysql)... and a php page will just
> read what's in the database to display it nicely.


That's what we do here. C/C++ app gathers and inserts the data into the db,
minute by minute, and PHP apps are used for display, reports, graphics,
etc... Our LAMP system has had nary a glitch in over 3 years of continuous
usage.

That would be a clean way of doing it.
>
> Good luck!



David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread David Giragosian
On 8/28/07, Simon <[EMAIL PROTECTED]> wrote:
>
> you can use sockets in php, they work the same as berkley sockets
> you can use system() in php, to call your C++ program (the program
> could output html)
> in my opinon CGI with C/C++ is obsolete, use php/apache for best results!
>
> another nice way is to have your C++ program independent, outputs its
> results/values into a database (mysql)... and a php page will just
> read what's in the database to display it nicely.


That's what we do here. C/C++ app gathers and inserts the data into the db,
minute by minute, and PHP apps are used for display, reports, graphics,
etc... Our LAMP system has had nary a glitch in over 3 years of continuous
usage.

That would be a clean way of doing it.
>
> Good luck!



David


Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread Simon
you can use sockets in php, they work the same as berkley sockets
you can use system() in php, to call your C++ program (the program
could output html)
in my opinon CGI with C/C++ is obsolete, use php/apache for best results!

another nice way is to have your C++ program independent, outputs its
results/values into a database (mysql)... and a php page will just
read what's in the database to display it nicely.
That would be a clean way of doing it.

Good luck!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] c++ and php! search for a brigde

2007-08-28 Thread dwa

Hello people,
i have a question??

I have an application written in c++ and this throw real time data as 
udp-pakets all the time (interval 1 min and values in a wrapper like an 
own protocol are floats and longs).


Is there any possibility to catch the udp packets - parse the pakets und 
show the values in tables in a html-doc in real time???


What technologies are good? ajax? cgi? ive no idea!

mfg
david

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search function

2007-05-09 Thread Chris

Ryan A wrote:

Hey!

.A little background:
We have a site that has already been made.. a couple of hundred pages displayed 
via SMARTY templates, the site's in Swedish.

The navigation and other parts except for the center is taken care of by the 
templates and other scripts... the center main text is taken from the 
database(mySql) based on $page_id...its in a MySql TEXT field and has all the 
html etc that will be displayed in the center of the page.

End of background..

Now they want to add a "search function" to the site... a simpe textbox where a user 
enters a word or sentance and they get 20 results per page... with a "x.xx % closest to your 
query"  can anybody give me basic pointers on where to start?
Any links/software or articles too would be appreciated...


http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html

Start off with that, if they need something more complicated down the 
line, revisit.


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search function

2007-05-09 Thread Richard Lynch
On Wed, May 9, 2007 7:34 am, Ryan A wrote:
> Now they want to add a "search function" to the site... a simpe
> textbox where a user enters a word or sentance and they get 20 results
> per page... with a "x.xx % closest to your query"  can anybody give me
> basic pointers on where to start?
> Any links/software or articles too would be appreciated...

You could google for "full text search" and "weighted search" and find
more than enough reading to fill the rest of your life... :-)

With only a couple hundred pages of content, it's kinda hard to really
make a good search engine...

You'd almost be better off just building a form that leads to Google
and using theirs, really.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search function

2007-05-09 Thread Ryan A
Hey!

.A little background:
We have a site that has already been made.. a couple of hundred pages displayed 
via SMARTY templates, the site's in Swedish.

The navigation and other parts except for the center is taken care of by the 
templates and other scripts... the center main text is taken from the 
database(mySql) based on $page_id...its in a MySql TEXT field and has all the 
html etc that will be displayed in the center of the page.

End of background..

Now they want to add a "search function" to the site... a simpe textbox where a 
user enters a word or sentance and they get 20 results per page... with a "x.xx 
% closest to your query"  can anybody give me basic pointers on where to start?
Any links/software or articles too would be appreciated...

(I can do the pagentation etc... just the search logic...)

Thanks!
R





--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
   
-
Ahhh...imagining that irresistible "new car" smell?
 Check outnew cars at Yahoo! Autos.

Re: [PHP] php search engine

2007-03-19 Thread Richard Lynch
On Mon, March 19, 2007 5:21 am, Ross wrote:
> I am looking for a php search engine that provides a suggested words
> (soundex?) when items are misspelt, the way google does.
>
> I have used http://www.site-search-pro.com/ i n the past which is
> great but
> as far as I know this feature is not included.

I suppose you could hack your own with http://php.net/soundex or any
of the other 3 or 4 similar packages available in PHP...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php search engine

2007-03-19 Thread tedd

At 4:50 PM +0100 3/19/07, Tijnema ! wrote:

On 3/19/07, Ross <[EMAIL PROTECTED]> wrote:

Hi,

I am looking for a php search engine that provides a suggested words
(soundex?) when items are misspelt, the way google does.

I have used http://www.site-search-pro.com/ i n the past which is great but
as far as I know this feature is not included.

Ross


I've never heard of such search machine, except from google then. But
i know the google code was released on warez boards. I'm not giving
you a link where to download, as it is illegal to have that code.

Tijnema


Ross:

I may be off-base here, (not a soundex example) but if a site search 
is all your after, try this one:


http://sperling.com/examples/search/

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php search engine

2007-03-19 Thread Tijnema !

On 3/19/07, Ross <[EMAIL PROTECTED]> wrote:

Hi,

I am looking for a php search engine that provides a suggested words
(soundex?) when items are misspelt, the way google does.

I have used http://www.site-search-pro.com/ i n the past which is great but
as far as I know this feature is not included.


Ross


I've never heard of such search machine, except from google then. But
i know the google code was released on warez boards. I'm not giving
you a link where to download, as it is illegal to have that code.

Tijnema


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php search engine

2007-03-19 Thread Ross
Hi,

I am looking for a php search engine that provides a suggested words 
(soundex?) when items are misspelt, the way google does.

I have used http://www.site-search-pro.com/ i n the past which is great but 
as far as I know this feature is not included.


Ross 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search script problem

2007-01-07 Thread Jochem Maas
top posting.

what sucks?

-

still having trouble keeping your posts on lists?
if you want to put me in my place, that's fine but please
keep it on list where it belongs - if only because private flames
wars are so boring.

Wikus Moller wrote:
> Oops, I gave you the wrong link, here is the correct one where you can
> gain some knowledge:
> 
> http://google.com/search?q=How+to+answer+questions+without+trying+to+look+smart
> 

firstly, I can't actually see anything very specific to the query in the 
results.
secondly the first item in the results is primarily aimed at *you* (given that
you asked the question).

with regard to this page: http://catb.org/~esr/faqs/smart-questions.html
I am aware of it, I've read it a number of times, it's been posted on this
list numerous times and at least 1 long time list member actually carries the
link in his signature.

with regard to the last section on that page entitled
'How To Answer Questions in a Helpful Way' I don't feel I
transgressed any on of the points made, other than possibly 'be gentle' -
obviously you didn't consider it a gentle reply but it was comparitively gentle
by my usual standards.

with regard to looking smart - I don't kind looking smart at all, I consider 
myself
smart & *reasonably* knowledge with regard to using php - not perfect, not 
gifted, not
exceptional in anyway, but smart nonetheless. if that makes you feel inferior
you have one simple recourse - become, in your mind, smarter than me :-) I'll 
welcome
it, it would mean one more mind on this list capable of solving problems and
help raise the level of php hacking in general.

> 
> 
> On 1/8/07, Wikus Moller <[EMAIL PROTECTED]> wrote:
>> Thats fine with me ^.^
>>
>> Here are some tips for you when you answer a question next time:
>>
>> http://google.com/search?p=How+to+answer+a+question+without+trying+to+look+smart
>>
>>
>> Thanks
>> Wikus
>>
>>
>> On 1/7/07, Jochem Maas <[EMAIL PROTECTED]> wrote:
>> > please keep it on the list.
>> >
>> > Wikus Moller wrote:
>> > > Let me repeat myself, SIMPLE, this was just the starting point.
>> >
>> > niether 'simple' or 'starting point' equate to 'ugly' or 'shit'
>> > though do they. even simple scripts deserve error checking and
>> > a managable layout.
>> >
>> > I wasn't pointing that out to make you feel bad but to give you a
>> > leg up in better script writing ...
>> >
>> > >
>> > > The error was caused due to a field being created after there were
>> > > already rows in the table.
>> >
>> > that *shouldn't* cause you any errors. the most likely reason it
>> > did is your scripts assumption of the physical field order of your
>> table.
>> >
>> > I would recommend not using mysql_fetch_array() instead switch to
>> > mysql_fetch_assoc() and reference the elements in the returned array
>> > by name rather than by number - this has 2 advantages:
>> >
>> > 1. you won't get bitten by fields that were added to the table after
>> > the script was written.
>> > 2. the output you generate using the returned array is alot more
>> > understandable:
>> >
>> > e.g. $row['name'] as compared to $row[0]
>> >
>> > >
>> > > It works like a dream and now I will correct the errors you pointed
>> > > out and which you assumed I didn't know and which had no relevance to
>> > > my query after I stated so boldly that it was simple.
>> >
>> > a. I merely assumed that you *may* not be aware of the things I pointed
>> > out, if you are aware of those points then there was really no harm
>> done,
>> > if you weren't then you would have been armed some new info ...
>> >
>> > b. you can't control the answer, only the question, stop trying :-)
>> >
>> > >
>> > > Thanks
>> >
>> > ...
>> >
>>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search script problem

2007-01-07 Thread Jochem Maas
please keep it on the list.

Wikus Moller wrote:
> Let me repeat myself, SIMPLE, this was just the starting point.

niether 'simple' or 'starting point' equate to 'ugly' or 'shit'
though do they. even simple scripts deserve error checking and
a managable layout.

I wasn't pointing that out to make you feel bad but to give you a
leg up in better script writing ...

> 
> The error was caused due to a field being created after there were
> already rows in the table.

that *shouldn't* cause you any errors. the most likely reason it
did is your scripts assumption of the physical field order of your table.

I would recommend not using mysql_fetch_array() instead switch to
mysql_fetch_assoc() and reference the elements in the returned array
by name rather than by number - this has 2 advantages:

1. you won't get bitten by fields that were added to the table after
the script was written.
2. the output you generate using the returned array is alot more understandable:

e.g. $row['name'] as compared to $row[0]

> 
> It works like a dream and now I will correct the errors you pointed
> out and which you assumed I didn't know and which had no relevance to
> my query after I stated so boldly that it was simple.

a. I merely assumed that you *may* not be aware of the things I pointed
out, if you are aware of those points then there was really no harm done,
if you weren't then you would have been armed some new info ...

b. you can't control the answer, only the question, stop trying :-)

> 
> Thanks

...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search script problem

2007-01-07 Thread Jochem Maas
Wikus Moller wrote:
> Hi.
> 
> I am having problems with a script I wrote which searches keywords
> from a field in a mysql db table.
> 
> It is a very simple,  one-page script. My site is a toplist, very
> basic, still in it's infancy. When I go to the page, key in the
> keywords and press submit, the head, body etc. part of the result
> script is shown, but no results.
> , although there are rows in my database containing the `keyword` field
> data.
> 
> Below is the script, please see if you find any errors, it could be
> that I just made a stupid mistake.

imho your first stupid mistake was writing a script that bloody
unmanagable.

1. check you input
2. do some processing
3. ouput your page (including any error msgs from step 1 and 2)

this is in contrast to the tactic your using, namely: dump some output,
do something, dump more output, perform a query, dump some output, do
stuff, dump some output in a loop, do stuff, dump some output, etc.

P.

read on ...

> 
>  
> echo "";
> echo " \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>";
> echo "http://www.w3.org/1999/xhtml\";>";
> 
> error_reporting(E_ALL ^ E_NOTICE);
> 
> $pwd = $_GET["pwd"];
> $uid = $_GET["uid"];
> $action = $_GET["action"];
> $cid = $_GET["cid"];
> $sid = $_GET["sid"];
> $var = $_GET["q"];


echo 'is this your expected input? : ';
var_dump($_GET)
echo '';

> 
> include ("function.php");
> include ("config.php");
> connect($dbserver,$dbname,$dbuser,$dbpass);
> 
> 
> 
> /Search main page
> if(!isset($var)){
> echo "";
> echo "Search Engine";
> echo "
> .m3 {background-color: #291C6F;}
>.n1 {background-color: #A0A0A0;}
>.n2 {background-color: #88;}
> .c2 {color: #00;}
> .m2 {color: #91D0FF;}
> body   {font-family: Arial, sans-serif;
> font-size: 12px;
> color: #ff;
> background-color: #33;
> margin-left: 0px;
> margin-right: 0px;
> margin-top: 0px;}
> .ct1 {font-family: Arial, sans-serif;
> font-size: 12px;
> color: #800080;}
> .cre {background-color: #1300A4;
> padding: 2px 2px 2px 2px;
> margin: 3px 0 0;
> font-size: 12px;
> color:#00;
> text-align: center;
> border-width:1px 0;
> border-style:solid;
> border-color:#00;}

use a css file and save a bit of band width (and scrolling in my case).

> ";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "Search Engine";
> echo " action=\"search.php?uid=$uid&pwd=$pwd\">"; ///the uid and pwd is
> nessecary cause my member features are very basic and the urls is used
> to keep the user 'logged in'

basic is the wrong word if your are thinking in terms of security -
non-existent is closer to the truth. http://phpsec.org is a good place to
and learn about security on all [php] fronts

> echo "Keywords: ";
> echo "";
> echo "";
> echo "";
> echo " href=\"index.php?uid=$uid&pwd=$pwd\">Home";
> echo "";
> echo "";
> }
> 
> ///Display Results
> 
> if(isset($var)){

the following line is pointless given the line about and the
fact that you have already set $var in exactly the same way at the
top of your script.

> $var = $_GET["q"];
> $trimmed = trim($var); //trim whitespace from the stored variable
> echo "";
> echo "Search Results";
> echo "
> .m3 {background-color: #291C6F;}
>.n1 {background-color: #A0A0A0;}
>.n2 {background-color: #88;}
> .c2 {color: #00;}
> .m2 {color: #91D0FF;}
> body   {font-family: Arial, sans-serif;
> font-size: 12px;
> color: #ff;
> background-color: #33;
> margin-left: 0px;
> margin-right: 0px;
> margin-top: 0px;}
> .ct1 {font-family: Arial, sans-serif;
> font-size: 12px;
> color: #800080;}
> .cre {background-color: #1300A4;
> padding: 2px 2px 2px 2px;
> margin: 3px 0 0;
> font-size: 12px;
> color:#00;
> text-align: center;
> border-width:1px 0;
> border-style:solid;
> border-color:#00;}
> ";
> echo "";
> echo "";
> echo "";
> echo "Search Results";
> echo "";
> // Get the search variable from URL
> 
> 
> 
> // check for an empty string and display a message.
> if ($trimmed == "")
>  {
>  echo "Please enter a search...";
>  exit;
>  }
> 
> 
> 
> if($pg==0)$pg=1;
>  $pg--;
>  $lmt = $pg*20;
>  $pg++;
>  $cou =$lmt+1;

is your table called 'table'? that is the WORST name in the world for
a table - and it will break your queries unless you stick them in backticks, 
e.g.:

$res = mysql_query("SELECT COUNT(*) FROM `table`");

>  $scount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM table

you are not checking the return value of mysql_query().
you need to lea

[PHP] Search script problem

2007-01-06 Thread Wikus Moller

Hi.

I am having problems with a script I wrote which searches keywords
from a field in a mysql db table.

It is a very simple,  one-page script. My site is a toplist, very
basic, still in it's infancy. When I go to the page, key in the
keywords and press submit, the head, body etc. part of the result
script is shown, but no results.
, although there are rows in my database containing the `keyword` field data.

Below is the script, please see if you find any errors, it could be
that I just made a stupid mistake.

";
echo "http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>";
echo "http://www.w3.org/1999/xhtml\";>";

error_reporting(E_ALL ^ E_NOTICE);

$pwd = $_GET["pwd"];
$uid = $_GET["uid"];
$action = $_GET["action"];
$cid = $_GET["cid"];
$sid = $_GET["sid"];
$var = $_GET["q"];

include ("function.php");
include ("config.php");
connect($dbserver,$dbname,$dbuser,$dbpass);



/Search main page
if(!isset($var)){
echo "";
echo "Search Engine";
echo "
.m3 {background-color: #291C6F;}
.n1 {background-color: #A0A0A0;}
.n2 {background-color: #88;}
.c2 {color: #00;}
.m2 {color: #91D0FF;}
body   {font-family: Arial, sans-serif;
font-size: 12px;
color: #ff;
background-color: #33;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;}
.ct1 {font-family: Arial, sans-serif;
font-size: 12px;
color: #800080;}
.cre {background-color: #1300A4;
padding: 2px 2px 2px 2px;
margin: 3px 0 0;
font-size: 12px;
color:#00;
text-align: center;
border-width:1px 0;
border-style:solid;
border-color:#00;}
";
echo "";
echo "";
echo "";
echo "";
echo "Search Engine";
echo ""; ///the uid and pwd is
nessecary cause my member features are very basic and the urls is used
to keep the user 'logged in'
echo "Keywords: ";
echo "";
echo "";
echo "";
echo "Home";
echo "";
echo "";
}

///Display Results

if(isset($var)){
$var = $_GET["q"];
$trimmed = trim($var); //trim whitespace from the stored variable
echo "";
echo "Search Results";
echo "
.m3 {background-color: #291C6F;}
.n1 {background-color: #A0A0A0;}
.n2 {background-color: #88;}
.c2 {color: #00;}
.m2 {color: #91D0FF;}
body   {font-family: Arial, sans-serif;
font-size: 12px;
color: #ff;
background-color: #33;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;}
.ct1 {font-family: Arial, sans-serif;
font-size: 12px;
color: #800080;}
.cre {background-color: #1300A4;
padding: 2px 2px 2px 2px;
margin: 3px 0 0;
font-size: 12px;
color:#00;
text-align: center;
border-width:1px 0;
border-style:solid;
border-color:#00;}
";
echo "";
echo "";
echo "";
echo "Search Results";
echo "";
// Get the search variable from URL



// check for an empty string and display a message.
if ($trimmed == "")
 {
 echo "Please enter a search...";
 exit;
 }



if($pg==0)$pg=1;
 $pg--;
 $lmt = $pg*20;
 $pg++;
 $cou =$lmt+1;
 $scount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM table
WHERE keywords like \"%$trimmed%\" AND banned='0' AND hitsin >=
'2'"));
 $pgs = ceil($scount[0]/20);
 // Build SQL Query
 $sql = "SELECT * FROM table WHERE keywords like \"%$trimmed%\" AND
banned='0' and hits_in >='2' ORDER by hin DESC LIMIT ".$lmt.", 20;";
// EDIT HERE and specify your table and field names for the SQL query
 $sites=mysql_query($sql);


while ($site = mysql_fetch_array($sites))
{
   $dscr =htmlspecialchars($site[11]);
   $snm=htmlspecialchars($site[1]);
   echo "$snm";
   echo "$dscr";
   $cou++;
}
$npage = $pg+1;
$ppage = $pg-1;
if($pg<$pgs)
//this is just for clicking on the site's name when the results are displayed
{

   $nlink = "Next";

}
if($pg >1)
{
   $plink = "Prev";
}


echo "$nlink";
echo "$plink";

echo "";
echo "Home";
echo "";
echo "";
}
?>

Like I said, very basic. I know there must be a screw-up somewhere but
I can't seem to find it.

Thanks
Wikus

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Search Results Accuracy

2006-12-18 Thread zoticaic
Thanks,

 

All I needed was that to get started with.

 

Regards

jervin

--
> Outsource Now | GetAFreelancer
<http://www.getafreelancer.com/affiliates/shockx/> 

  _  

From: Shafiq Rehman [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 19, 2006 2:41 PM
To: zoticaic
Subject: Re: [PHP] Search Results Accuracy

 

Hello,

In searching, "like" queries are not recommended because these are the most
slowest queries. You must use full text searching. It will rocks your search
speed and suits your scenario. Here is an article for fulltext searching 

http://www.onlamp.com/pub/a/onlamp/2003/06/26/fulltext.html

-- 
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com



On 12/19/06, zoticaic <[EMAIL PROTECTED]> wrote:

Hi,

 

I'm not really sure which is the best path to go but let me give you an example
scenario : 

1. We already have a database of varchar data : 

+---+

|   links  |

+---+

| 340-golfers-dream-and-swimmers|

+---+

| 89-golfers-dream   |

+---+

| 45-golf-equipments|

+---+

| 3-best-golf-training |

+---+

| 0-golf-equipment-and-training  |

+---+

| 39-golf-training  |

+---+



 

2. From data above if we search the database for '%golf%' it would return all
rows as results, if we search for '%golf%training%' it would return three rows .

 

How do I choose from the multiple results? For the '%golf%' query, the desired
result is golf-equipments or golf-training, while for '%golf%training%' the
desired result should be 39-golf-training alone . This is sort of like search
engine ranking their results, but for this how do I set the criteria using MySQL
queries or if not possible using PHP .

 

I hope it makes it more clear, questions are welcomed.

 

TIA

Jervin

 

--
> Outsource Now | GetAFreelancer
<http://www.getafreelancer.com/affiliates/shockx/>  

  _  

From: Shafiq Rehman [mailto: [EMAIL PROTECTED] 
Sent: Tuesday, December 19, 2006 2:07 PM
To: zoticaic
Subject: Re: [PHP] Search Results Accuracy

 

Hello,

Your question is not very clear, please elaborate it.

btw, Are you talking about the fulltext search?

-- 
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com  <http://www.phpgurru.com> 

On 12/19/06, zoticaic <[EMAIL PROTECTED]> wrote:

Hello,



I'm just wondering, from a list of search results from a database query, how do
we trim down and return the most accurate one?



Hints, links and suggestions are most welcome.



TIA

Jervin



--
> Outsource Now | GetAFreelancer
<http://www.getafreelancer.com/affiliates/shockx/>














Re: [PHP] Search Results Accuracy

2006-12-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-19 09:33:02 +0800:
> Hello,
> 
>  
> 
> I'm just wondering, from a list of search results from a database query, how 
> do
> we trim down and return the most accurate one? 
> 
>  
> 
> Hints, links and suggestions are most welcome.

is this what you're looking for?

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Search Results Accuracy

2006-12-18 Thread zoticaic
Hi,

 

I'm not really sure which is the best path to go but let me give you an example
scenario : 



1. We already have a database of varchar data : 

+---+

|   links  |

+---+

| 340-golfers-dream-and-swimmers|

+---+

| 89-golfers-dream   |

+---+

| 45-golf-equipments|

+---+

| 3-best-golf-training |

+---+

| 0-golf-equipment-and-training  |

+---+

| 39-golf-training  |

+---+



 

2. From data above if we search the database for '%golf%' it would return all
rows as results, if we search for '%golf%training%' it would return three rows .

 

How do I choose from the multiple results? For the '%golf%' query, the desired
result is golf-equipments or golf-training, while for '%golf%training%' the
desired result should be 39-golf-training alone . This is sort of like search
engine ranking their results, but for this how do I set the criteria using MySQL
queries or if not possible using PHP .

 

I hope it makes it more clear, questions are welcomed.

 

TIA

Jervin

 

--
> Outsource Now | GetAFreelancer
<http://www.getafreelancer.com/affiliates/shockx/> 

  _  

From: Shafiq Rehman [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 19, 2006 2:07 PM
To: zoticaic
Subject: Re: [PHP] Search Results Accuracy

 

Hello,

Your question is not very clear, please elaborate it.

btw, Are you talking about the fulltext search?

-- 
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com  <http://www.phpgurru.com> 



On 12/19/06, zoticaic <[EMAIL PROTECTED]> wrote:

Hello,



I'm just wondering, from a list of search results from a database query, how do
we trim down and return the most accurate one?



Hints, links and suggestions are most welcome.



TIA

Jervin



--
> Outsource Now | GetAFreelancer
<http://www.getafreelancer.com/affiliates/shockx/>











[PHP] Search Results Accuracy

2006-12-18 Thread zoticaic
Hello,

 

I'm just wondering, from a list of search results from a database query, how do
we trim down and return the most accurate one? 

 

Hints, links and suggestions are most welcome.

 

TIA

Jervin

 

--
> Outsource Now | GetAFreelancer
 

 



Re: [PHP] PHP Search Engine - Synonyms

2006-10-30 Thread Ed Lazor


On Oct 30, 2006, at 6:26 AM, Kevin wrote:


Hi,

Is it possible to automatically search for synonyms related to a  
word in a search engine for example if I create a search engine and  
search for the word 'Horse', it would automatically search for  
other words such as 'Pony' etc?


It is possible:  http://www.google.com/help/refinesearch.html


Has anyone had any experience on how this would be implemented?


I haven't done it, but it seems straight forward.  Start with one  
word, query a database for it's synonyms, and then use the resulting  
words (including the original word) in the final search query.  It  
just seems like it would take a lot of work to create a database of  
words and their synonyms.  You'll also need to add weight and sort  
the results so that your initial keyword scores higher.  Honestly, if  
I were you, I'd run this question by the MySQL mailing list.  PHP  
just works with the results of the search, so you still end up having  
to figure out how to do this in MySQL (or whatever database you're  
using).  Another thing that might help is to Google keywords like  
"synonym search programming technique".  I had to sort through the  
results, but it did look like there were a few interesting articles.   
Here's one of them:  http://developer.apple.com/documentation/ 
UserExperience/Conceptual/SearchKitConcepts/searchKit_basics/ 
chapter_2_section_2.html


-Ed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Search Engine - Synonyms

2006-10-30 Thread Ed Lazor
Another idea from what I just sent:  try googling "synonym  
database".  It looks like there are a few leads in there as well.


On Oct 30, 2006, at 6:26 AM, Kevin wrote:


Hi,

Is it possible to automatically search for synonyms related to a  
word in a search engine for example if I create a search engine and  
search for the word 'Horse', it would automatically search for  
other words such as 'Pony' etc?


Has anyone had any experience on how this would be implemented?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP Search Engine - Synonyms

2006-10-30 Thread Kevin

Hi,

Is it possible to automatically search for synonyms related to a word in 
a search engine for example if I create a search engine and search for 
the word 'Horse', it would automatically search for other words such as 
'Pony' etc?


Has anyone had any experience on how this would be implemented?

Thanks

Kevin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Search and Privacy...

2006-10-24 Thread Russell Jones

You're right - i dont know if there is even a standards body that would
cover something like this. I am assuming, along with that answer, that none
of the popular php site search tools have implemented it yet. Ill see if i
can throw something into one of the more common scripts...

Russ

On 10/23/06, Chris <[EMAIL PROTECTED]> wrote:


Russell Jones wrote:
> Does anyone know if any of the PHP Site-Search tools have implemented
the
> new #privacy search standard (http://www.poundprivacy.org). Looking to
> install a new site-search and I would really like to install something
that
> is compliant...

Don't know of any off hand but that site looks like a campaign to make
something happen, not a standard. Two completely different things.

"Pound Privacy" is a *campaign* to create the first standard for search
engine query privacy.

--
Postgresql & php tutorials
http://www.designmagick.com/



Re: [PHP] PHP Search and Privacy...

2006-10-23 Thread Chris

Russell Jones wrote:

Does anyone know if any of the PHP Site-Search tools have implemented the
new #privacy search standard (http://www.poundprivacy.org). Looking to
install a new site-search and I would really like to install something that
is compliant...


Don't know of any off hand but that site looks like a campaign to make 
something happen, not a standard. Two completely different things.


"Pound Privacy" is a *campaign* to create the first standard for search 
engine query privacy.


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP Search and Privacy...

2006-10-23 Thread Russell Jones

Does anyone know if any of the PHP Site-Search tools have implemented the
new #privacy search standard (http://www.poundprivacy.org). Looking to
install a new site-search and I would really like to install something that
is compliant...


  1   2   3   4   5   >