first, thanks again for your response, I appreciate your help more than you know. The only reason I am trying to mod this script and return the results in such a weird way is because I want to be able to fade in new entries individually rather than just update all data, which is how I did it myself and does not look very nice to the end user. You are making very keen observations, as far as the timestamp goes. They should be the same which is just an 10 digit integer. for example, in my database time entries look like 1269058642 which is what they looked like in the original messages.txt. When I pass my information back, I do it in a chunk like the orginal file, like this.
Code: Select all
require_once('JSON.php');
$json = new Services_JSON();
$out = $json->encode($data);
print $out;
The thing I do not understand is that, functionality works perfectly in the first script but when you change to mine it goes haywire, so that is why I thought foreach was somehow necessary to go through array results. Can't you use a while statement to get all results, then traverse them using a foreach like this?
Code: Select all
while($row = mysql_fetch_array( $result )) {
$new=$row['fieldname'];
$new_array[] = $new;
}
foreach($new_array as $key => $value) {
echo $key. " - " . $value . "<br />";
}
For example, I tried this but it does not work
Code: Select all
while( $row = mysql_fetch_array($res) ){
$aTemp = null;
list($aTemp['time'], $aTemp['user'], $aTemp['message']) = $row;
$data[] = $aTemp;
}
foreach($aTemp as $value){
if($aTemp['message'] AND $aTemp['time'] > $_GET['time'])
$data[] = $aTemp;
}
If you want to see the code I am experimenting with, you can find it at
http://www.ajaxdaddy.com/demo-jquery-shoutbox.html I just want to figure out this darn query so I can implement this kind of fade in structure with my own previous code, but I need to understand how to fetch the information properly first. I think it may be because mysql_fetch_array returns rows, and in the original file file(message.txt) assigns the entire document to an array, so is it possible to do the same with the mysql data.