I'll be brief... I'm about to jump
not all results are working
in the document header I am including jquery-1.7.2.min.js -
my query:
"SELECT tableA.columns_xyz..., tableB.columns_xyz..., tableC.columns_xyz
FROM tableB
JOIN tableC ON tableB.x = tableC.x
JOIN tableA ON tableB.x = tableA.x
WHERE tableA.x = '$query_value'
GROUP BY tableA.y
ORDER BY tableA.y DESC
LIMIT 1";
PROBLEM 1:
change LIMIT 1 to LIMIT 5 or anything >1 and the query executes fine in phpmyadmin but not via ajax/json/php
the php:
$sql = above...
$result = $mysqli->query($sql);
while($row = mysqli_fetch_array($result)) {
echo json_encode(array($row['x'],$row['y'],....$row['z']));
$mysqli->close();
the javascript:
$.ajax ({
url: 'script.php',
type: "post",
dataType: "json",
data: {value : $("#searchbox").val()},
success: function(data) {
var a = parseFloat(data[0]);
var b = parseFloat(data[1]);
var c = data[2];
document.getElementById("blah1").innerHTML = a;
document.getElementById("blah2").innerHTML = b;
document.getElementById("blah3").innerHTML = c;
}
});
the html:
<td><span id="blah1"></span></td>
<td><span id="blah2"></span></td>
<td><span id="blah3"></span></td>
PROBLEM 2:
some elements are printing to page, some aren't. what am I doing wrong ?
PROBLEM 3:
I know I should be able to express document.getElementById("blah1").innerHTML; as $('#blah1'); but $('#blah1'); is just not working... I don't know why...