Ok, so im a bit further on with this....
basically I have a php page which pulls fields from the database:
<?php
// Database credentials
$host = 'xx';
$db = 'xx';
$uid = 'xx';
$pwd = 'xx';
// Connect to the database server
$link = mysql_connect($host, $uid, $pwd) or die("Could not connect");
//select the json database
mysql_select_db($db) or die("Could not select database");
// Create an array to hold our results
$arr = array();
//Execute the query
$rs = mysql_query("SELECT id,userid,firstname,lastname,email FROM users");
// Add the rows to the array
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
//return the json result. The string users is just a name for the container object. Can be set anything.
echo '('.json_encode($arr).');';
?>
If you view the page it gives you the json query: http://www.garethmoore.net/jq.php
([{"id":"1","userid":"fhardy","firstname":"Frank","lastname":"Hardy","email":"fhardy@hauntedclock.com"},{"id":"2","userid":"jhardy","firstname":"Joe","lastname":"Hardy","email":"jhardy@hauntedclock.com"},{"id":"3","userid":"ndrew","firstname":"Nancy","lastname":"Drew","email":"ndrew@hauntedclock.com"},{"id":"4","userid":"sdoo","firstname":"Scooby","lastname":"Doo","email":"sdoo@mysterymachine.com"}]);
Then I have my HTML page (which is just stored on my loacl hard drive. This is the HTML/Javascript code:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.getJSON('http://www.garethmoore.net/jq.php?count=20&callback=?', function(data){
$.each(data, function(index, item){
$('#twitter').append('<div class="tweet"><p>' + item.email + '</p></div>');
});
});
});
</script>
</head>
<body>
<div id="twitter" >
</div>
</body>
</html>
Ive pretty much taken the HTML/javascript from a Twitter feed that ive used loads before and it works. But for some reason, even though the code is the same, and the json output is the same (as the twitter output) this just doesnt seem to work.