PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$sql = $database->query("SELECT * FROM `email` WHERE `CompanyID`='{$_SESSION['CLIENT']['ID']}' AND `Type` != 'Forwarder' ORDER BY Type ASC, Address ASC");
while($email = $database->fetch_assoc($sql))
{
... etc
Currently certain fields are encrypted and a I have a small object called crypt() that decodes it correctly.
So when I output a value that is encrypted I do:
The problem I have is that I cant sort the data properly as the SQL statement above simply sorts the enrypted data.
Can anybody suggest the simplest way I could decrypt the data and sort it before it is output?
$sql = $database->query("SELECT * FROM `email` WHERE `CompanyID`='{$_SESSION['CLIENT']['ID']}' AND `Type` != 'Forwarder'");
if ($database->num_rows($sql) < 1)
{
echo '<tr><td colspan="3"><em>This client has no e-mail accounts.</em></td></tr>';
}
// Fetch all of the items into an array:
while ($arr_AddressHolder_encoded = $database->fetch_assoc($sql))
{
foreach ($arr_AddressHolder_encoded as $key => $value)
{
if ($key == "ID" OR $key == "CompanyID" OR $key == "Type" OR $key == "HasSpam")
{
$item[$key] = $value;
} else {
$item[$key] = $crypt->decrypt($value);
}
}
$arr_AddressHolder[] = $item;
}
array_multisort("CompanyID", SORT_DESC, $arr_AddressHolder);
//while($email = $arr_AddressHolder)
foreach($arr_AddressHolder as $email)
{
.... etc
I'm not sure i've passed the correct parameters to array_multisort() - I found the php.net manual a little confusing when I tried to apply its example to my code.
Hopefully the server will be back up soo an I can test it properly!