Using mysql_fetch_array()
's default arguments, your SQL query returns both an indexed and associative array entry for each row.
Firstly, I strongly suggest that you stay away from mysql_*
style functions. This set of tools has been deprecated for a while now, and is no longer being updated. There's plenty of resources online which explain why in more detail, and some good alternatives. Alas, let's move on.
Next, I advise that (if you need to use this function) you use one return format method or the other, by passing either MYSQL_ASSOC
(associative array) or MYSQL_NUM
(numbered array) into the function as it's second argument.
E.g. MYSQL_ASSOC
will give you:
Array
(
[title] => bbbbbb
[id] => 86
[subject] => rewr
[date_time] => 0000-00-00
[username] => admin
)
Generally, this is favored above a numbered array because you don't have to rely on the order that you have selected your columns in within your query.
E.g. MYSQL_NUM
will give you:
Array (
[0] =>aaaaaaa
[1] => 86
[2] => rewr
[3] => 0000-00-00
[4] => admin
)
Right. Now, to edit the array in your while loop, you can just add the following lines:
// Using MYSQL_ASSOC
while ( $aRow = mysql_fetch_array( $rResult , MYSQL_ASSOC ) ) {
$aRow['date_time'] = '2010-01-01';
$aRow['status'] = 'edited'; // Whatever key this column should be needs to be added instead of 'status'
$output['aaData'][] = $aRow;
}
Or:
// Using MYSQL_NUM
while ( $aRow = mysql_fetch_array( $rResult , MYSQL_NUM ) ) {
$aRow[3] = '2010-01-01';
$aRow[6] = 'edited';
$output['aaData'][] = $aRow;
}
If you still want to stick with both, you'll need to use the lines from both examples:
// Using DEFAULT / MYSQL_BOTH
while ( $aRow = mysql_fetch_array( $rResult ) ) {
$aRow['date_time'] = '2010-01-01';
$aRow[3] = '2010-01-01';
$aRow['status'] = 'edited'; // Whatever key this column should be needs to be added instead of 'status'
$aRow[6] = 'edited';
$output['aaData'][] = $aRow;
}