Jump to content

Complicated PHP/MSSQL Query - help needed


laural

Recommended Posts

I have a stored procedure on MSSQL that returns a list of results.  This works fine.  The results that are returned may or may not be allowed to be seen by the end user.  So, if 10 results are returned, maybe 7 of them are allowed to be viewed by the end user.  There is a PHP SESSION variable that contains a bunch of codes that is compared to a variable returned from the search result. When these match, the result can be seen by the user.

 

So, I am using a php if statement that echos the result based on the result of the if statement.  That works fine.  What does not work  is the found count for the array.  For example, if 10 are found, it returns 10, but the if statement removes 3 making 7 of the results viewable. 

 

So, is there a way to iterate through an array result set in PHP and remove results based on an if statement creating a new array?

 

Hope this is not too confusing!  :D

Link to comment
https://forums.phpfreaks.com/topic/261713-complicated-phpmssql-query-help-needed/
Share on other sites

Sure.

 

$old_array = array(1,2,3,4,5,6,7,8,9,10);

$new_array = array();

foreach($old_array as $old)
{
if ($old != 3 && $old != 5 && $old != 7) {
	$new_array[] = $old;
}		
}

/* $new_array = Array
(
[0] => 1,
[1] => 2,
[2] => 4,
[3] => 6,
[4] => 8,
[5] => 9,
[6] => 10
)
*/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.