I’m pretty new to php and I’m having trouble with getting the results I want from a SQL result. I am using MS-SQL stored procedures so I don’t have the luxury of modify my query so have to figure it out with the results I get.
I have an array that ends up looking like this. (Small example)
array(27194)
{ [0]=> array(2)
{
["Address"]=> string(34) "1000 N Front Street"
["Name"]=> string(5) "1"
}
[1]=> array(2)
{
["Address"]=> string(40) "1001 N Front Street"
["name"]=> string(5) "Test user2"
}
What I want to return is only the “name” key and only the values that are non-numeric. I don’t want to see any users that start with a number. I’m putting this info into a select dropdown.
My code so far is this.
[php]
$sql_statement = mssql_init("[sp_GETusers]", $cs);
$result=mssql_execute($sql_statement);
$UserList = array();
while ($row = mssql_fetch_assoc($result))
{
array_push($UserList,$row);
}
return $UserList;
[/php]
I’m able to get the list to populate with the “name” value. I just don’t want to have all the numbers as well.
[php]
<?php $Users = sp_GetPeople(); //call the sp... function in functions.php ?> <label for="user"><span class="required">* </span>Select User</label>
<select id="user" name="user" class="required">
<option value="">--Search User--</option>
<?php
foreach ($Users as $User)
echo "<option value=$User[name] >$User[name]</option>";
?>
[/php]
Is there a better way to get that info other then ***_fetch_assoc and array_push? Plus filtering the numeric values?
Thanks for any advice or help.