MYSQL FETCH, FOR EACH, SO CLOSE! PLEASE HELP!
Posted: Fri Mar 19, 2010 1:42 am
SEE BOTTOM POST, I JUST NEED TO FIGURE OUT FOR EACH WITH MYSQL QUERY
I tried this but it doesn't work
I tried this but it doesn't work
Code: Select all
$link = connect(HOST, USER, PASSWORD);
$res = getContent($link, 500, 69);
if(!$_GET['time'])
$_GET['time'] = 0;
$aTemp = null;
while($row = mysql_fetch_array($res)){
//not sure what to do...they use a list format, I am not sure what javascript will recognize
}Code: Select all
case 'view':
$data = array();
$arr = file('messages.txt');
if(!$_GET['time'])
$_GET['time'] = 0;
foreach($arr as $row) {
$aTemp = null;
list($aTemp['time'], $aTemp['nickname'], $aTemp['message']) = explode('|', $row);
if($aTemp['message'] AND $aTemp['time'] > $_GET['time'])
$data[] = $aTemp;
}
//file_put_contents('debug.txt', print_r($data, true));
break;Code: Select all
function refresh() {
$.getJSON(files+"daddy-shoutbox.php?action=view&time="+lastTime, function(json) {
if(json.length) {
for(i=0; i < json.length; i++) {
$('#daddy-shoutbox-list').append(prepare(json[i]));
$('#list-' + count).fadeIn('slow');
}
var j = i-1;
lastTime = json[j].time;
}
//alert(lastTime);
});
timeoutID = setTimeout(refresh, 3000);
}
// wait for the DOM to be loaded
$(document).ready(function() {
var options = {
dataType: 'json',
beforeSubmit: validate,
success: success
};