I'm trying to use php to run a sql select statement to pull data from a database and then only output one column(username) to an array that I can then use to filter using a JS script. Similar to how facebook/twitter does their real time searching of contacts when you start typing someone's name in. I keep getting an error though in php when I try to pull the username column and set it to an array and output that:
<?php
session_start();
include_once 'dbconnect.php';
$contact = mysql_real_escape_string($con, $_POST['contact']);
$sql = "select * from users";
$result = $con->query($sql);
if ($result->num_rows > 0) {
($row = $result->fetch_assoc()) {
printf($row["username"]);
}
} else {
echo "0 results";
}
?>