What I'm trying to do is make a search function that if given the info will search the database and remove replicas and display the results.
First the search info is taken from the text box and put into an array (jo was the subject of the search):
A counter is setup so it know how many times to run the search loop
The Counter is set to 0
Then the primary stuff happens:
This is where I'm dropping the ball:
What I would like it do is APPEND/ADD the current array contents to the array $WaitNameResults but its not.
This is what it outputs:
this is the search param count 1
Fname and Lname is from fetch array is John Smith
Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 ) is the print_r version
print_r of WaitNameResults is: Array ( )
Fname and Lname is from fetch array is Johnny Drama
Array ( [0] => Johnny [Fname] => Johnny [1] => Drama [Lname] => Drama [2] => 592 [RLID] => 592 [3] => 15 [WID] => 15 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
Fname and Lname is from fetch array is Jon Jon
Array ( [0] => Jon [Fname] => Jon [1] => Jon [Lname] => Jon [2] => 592 [RLID] => 592 [3] => 21 [WID] => 21 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
Fname and Lname is from fetch array is Jon Jon
Array ( [0] => Jon [Fname] => Jon [1] => Jon [Lname] => Jon [2] => 592 [RLID] => 592 [3] => 22 [WID] => 22 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
Fname and Lname is from fetch array is Jon Jon
Array ( [0] => Jon [Fname] => Jon [1] => Jon [Lname] => Jon [2] => 592 [RLID] => 592 [3] => 23 [WID] => 23 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
The final contents of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
From this I know a few things:
1. The SQL is fine, its pulling the results into mysql_fetch_array
2. $WaitNameResult has the current info each time during the loop
3. $WaitNameResults = $WaitNameResults + $WaitNameResult; Worked at the begining changing the contents of $WaitNameResults from Array() to the first iteration of $WaitNameResult.
4. It doesn't append/add anything after that.
i tried using array_merge but got the same unsuccessful result. Again what I'm trying to do is get each of those lines into an array so I can run array_unique on the end result and then display them. using SELECT DISTINCT at the mysql level doesn't solve the problem because a diff query is being run for each word from the explode so the duplication check has to be ran after all the data is accumulated. Any help would be appreciated. thanks.
First the search info is taken from the text box and put into an array (jo was the subject of the search):
PHP:
$Search = array_unique( explode(" ", mysql_real_escape_string($_POST['Search'])));
A counter is setup so it know how many times to run the search loop
PHP:
$SearchParamCount = count($Search);
The Counter is set to 0
PHP:
$Counter = 0;
Then the primary stuff happens:
PHP:
$WaitNameResults = array();
while ( $Counter < $SearchParamCount) {
$Current = $Search[$Counter];
//$WaitNameObtain = "SELECT Fname, Lname, RLID, WID FROM Wait WHERE (Fname LIKE '%" .$Current . "%') OR (Lname LIKE '%" . $Current . "%') ";
$WaitNameObtain = "SELECT Fname, Lname, RLID, WID FROM Wait WHERE (Fname LIKE '%$Current%') OR (Lname LIKE '%$Current%') ";
$WaitNameQuery = mysql_query($WaitNameObtain);
while ($WaitNameResult = mysql_fetch_array($WaitNameQuery)){
echo ' Fname and Lname is from fetch array is ' . $WaitNameResult['Fname'] . ' ' . $WaitNameResult['Lname'] . '<br>';
print_r($WaitNameResult);
echo ' is the print_r version <br> print_r of WaitNameResults is: ';
print_r($WaitNameResults);
echo '<br>';
$WaitNameResults = $WaitNameResults + $WaitNameResult;
}
$Counter++;
} // ends while loop
// $WaitNameResults = array_unique($WaitNameResults);
echo '<br> The final contents of WaitNameResults is: ';
print_r($WaitNameResults);
$WaitNameCount = count($WaitNameResults);
} //ends else
This is where I'm dropping the ball:
PHP:
$WaitNameResults = $WaitNameResults + $WaitNameResult;
What I would like it do is APPEND/ADD the current array contents to the array $WaitNameResults but its not.
This is what it outputs:
this is the search param count 1
Fname and Lname is from fetch array is John Smith
Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 ) is the print_r version
print_r of WaitNameResults is: Array ( )
Fname and Lname is from fetch array is Johnny Drama
Array ( [0] => Johnny [Fname] => Johnny [1] => Drama [Lname] => Drama [2] => 592 [RLID] => 592 [3] => 15 [WID] => 15 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
Fname and Lname is from fetch array is Jon Jon
Array ( [0] => Jon [Fname] => Jon [1] => Jon [Lname] => Jon [2] => 592 [RLID] => 592 [3] => 21 [WID] => 21 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
Fname and Lname is from fetch array is Jon Jon
Array ( [0] => Jon [Fname] => Jon [1] => Jon [Lname] => Jon [2] => 592 [RLID] => 592 [3] => 22 [WID] => 22 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
Fname and Lname is from fetch array is Jon Jon
Array ( [0] => Jon [Fname] => Jon [1] => Jon [Lname] => Jon [2] => 592 [RLID] => 592 [3] => 23 [WID] => 23 ) is the print_r version
print_r of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
The final contents of WaitNameResults is: Array ( [0] => John [Fname] => John [1] => Smith [Lname] => Smith [2] => 1298 [RLID] => 1298 [3] => 3 [WID] => 3 )
From this I know a few things:
1. The SQL is fine, its pulling the results into mysql_fetch_array
2. $WaitNameResult has the current info each time during the loop
3. $WaitNameResults = $WaitNameResults + $WaitNameResult; Worked at the begining changing the contents of $WaitNameResults from Array() to the first iteration of $WaitNameResult.
4. It doesn't append/add anything after that.
i tried using array_merge but got the same unsuccessful result. Again what I'm trying to do is get each of those lines into an array so I can run array_unique on the end result and then display them. using SELECT DISTINCT at the mysql level doesn't solve the problem because a diff query is being run for each word from the explode so the duplication check has to be ran after all the data is accumulated. Any help would be appreciated. thanks.