I am selecting some data from my database and I can echo it with PHP in my document. How can I straight pass it to JavaScript, or it its not duable, how do people deal with these things?
Here is how I get and echo:
$q=mysql_real_escape_string($_GET['q']);
$query="SELECT * FROM contacts WHERE id = '".$q."'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
echo "Name: " . $row['first'] . " <br />";
echo "Surname: " . $row['last'] . " <br />";
}
mysql_close();
json_encodewhich then tries to encoded the already encoded data ;-)