MySQL select using an array
<p>I edit my code working good but still one problem ... the data that selected from my database and displayed in my suggestion input ( only one row and last ID ) !!! How can I do it to display all data rows from my database ????   </p>

<pre><code>&lt;?php
$q = strtolower($_GET["q"]);

if (!$q) return;

$host = "localhost";
$user = "root";
$password = "";
$database = "private_message_system";

//make connection
$server = mysql_connect($host, $user, $password);
$connection = mysql_select_db($database, $server);

$query = mysql_query("SELECT * FROM users");


while($row = mysql_fetch_array($query)){


    $items = array($row["user_name"] =&gt; $row["user_email"]);    

}

$result = array();

foreach ($items as $key=&gt;$value) {
if (strpos(strtolower($key), $q) !== false) {

    array_push($result, array(
        "name" =&gt; $key,
        "to" =&gt; $value
    ));
}
}

echo json_encode($result);
?&gt;
</code></pre>
