This is where the array of "objects" is generated:
while ($row = mysql_fetch_object ($result,MYSQL_ASSOC)) {
$my_array[] = $row;
}
Next I want to pass the array of objects to a function an process every object and add a data element to each object:
$vb_dblink = do_db_connect ($GLOBALS['vb_dbhost'],$GLOBALS['vb_dbname'],$GLOBALS['vb_dbusername'],$GLOBALS['vb_dbpassword']);
foreach ($my_array as $row) {
$row = vb_get_replycount ($vb_dblink,$row);
}
mysql_close ($vb_dblink);
The problem is that in my function vb_get_replycount the OBJECTS are not being updated!
Here is the function:
function vb_get_replycount ($vb_dblink, $row) {
foreach ($array as $row) {
$sql = "select replycount from thread where thread.threadid=\"$row->vb_threadid\"";
print "SQL = $sql<BR>";
if (!($result_row = mysql_query ($sql, $vb_dblink))) {
$row->replycount = "N/A";
}
else {
$object = mysql_fetch_object ($result_row,MYSQL_ASSOC);
$row->replycount = $object->replycount;
}
print "COUNT = $row->replycount<BR>";
}
}
The problem is that back in main program $row->replycount isn't there?
Any ideas?
Thanks!