title: Searching encrypted data
body: <p>I have some a database that has a bunch of 'normal' data in it as well as a first and last name which are encrypted.</p>
  
  <p>I have a PHP page which gets that data and in the MySQL statement, orders it by last name. </p>
  
  <p>It then prints the information on the page using a while loop and this page also has a simple first/last name search.</p>
  
  <p>I have two issues I'm not sure how to resolve:</p>
  
  <ol>
  <li><p>How do I order the data by last name, the MySQL statement does an order by  but as the last name is encrypted, the wrong order once decrypted.</p></li>
  <li><p>How do I get my search to work? Currently if the post variable isset, it adds to the MySQL query, but again this queries encrypted data so doesn't work.</p></li>
  </ol>
  
  <p>I'm guessing I need to get my data out, and pass it into a new array whilst decrypting the names, then sort that array. Then I can also apply my search to that array too.</p>
  
  <p>If the above is correct, I'm not sure how to do it, I've given it ago but I can't figure out how to decrypt my data whilst passing it into a new array. My decrypt function accepts two parameters, the data and the encryption key and I couldn't get an array_walker to work...</p>
  
  <p>I think if I solve the first issue I can figure out how to search.</p>
  
  <p>Please help!!</p>