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: [PHP] search array for value

2001-07-31 Thread Lenar

> > How do I search an array?
> >
> > For example if I want to know if $array contains "1"...
> >
> > Regards,
> >
> > Matthew Delmarter
> >
>
This is bad, use in_array() or array_search().
in_array() returns TRUE if element is found in array.
array_search returns the key of matching element, FALSE otherwise.

Lenar

> for ($i = 0; $i < count($array); $i++)
> {
> if ($array[$i] == 1) {
> //do something
> exit;
> }
> }
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] search array for value

2001-07-30 Thread Warren Vail

Sorry, mixed this up with your other query;

For this

If(in_array(1, $array))  {
}

Warren Vail

-Original Message-
From:   Warren Vail [mailto:[EMAIL PROTECTED]]
Sent:   Monday, July 30, 2001 9:57 PM
To: Matthew Delmarter; PHP Mailing List
Subject:RE: [PHP] search array for value

How about;

$valuelist = explode(", ", $array);
$query = "select * from table where column in ($valuelist)";
etc.

Warren Vail 

-Original Message-
From:   Matthew Delmarter [mailto:[EMAIL PROTECTED]]
Sent:   Monday, July 30, 2001 9:41 PM
To: PHP Mailing List
Subject:    [PHP] search array for value

How do I search an array? 

For example if I want to know if $array contains "1"...

Regards,

Matthew Delmarter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] search array for value

2001-07-30 Thread Warren Vail

How about;

$valuelist = explode(", ", $array);
$query = "select * from table where column in ($valuelist)";
etc.

Warren Vail 

-Original Message-
From:   Matthew Delmarter [mailto:[EMAIL PROTECTED]]
Sent:   Monday, July 30, 2001 9:41 PM
To: PHP Mailing List
Subject:    [PHP] search array for value

How do I search an array? 

For example if I want to know if $array contains "1"...

Regards,

Matthew Delmarter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] search array for value

2001-07-30 Thread DrWebPat

In a message dated 7/31/01 12:32:59 AM Eastern Daylight Time, 
[EMAIL PROTECTED] writes:


> How do I search an array? 
> 
> For example if I want to know if $array contains "1"...
> 
> Regards,
> 
> Matthew Delmarter
> 

for ($i = 0; $i < count($array); $i++)
{
if ($array[$i] == 1) {
//do something
exit;
}
}



[PHP] search array for value

2001-07-30 Thread Matthew Delmarter

How do I search an array? 

For example if I want to know if $array contains "1"...

Regards,

Matthew Delmarter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]