I want to get the result from the current and the last row from mysqli so I can see how the values changed. I need this for a statistical counter for my website
This is my code so far:
while ($row = $Result->fetch_object())
{
echo '
<tr>
<td>'.add_date_create($row->stat_AddTime).', '.add_time_create($row->stat_AddTime).'</td>
<td>'.$row->stat_hacks_view.' +('.$row->stat_hacks_view-$row_stat_hacks_view--.')</td>
<td>'.$row->stat_hacks_count.'</td>
<td>'.$row->stat_game_view.'</td>
<td>'.$row->stat_dev_count.'</td>
</tr>
';
}
[...]
The result should be something like this:
I hope I could explain what I mean.
I want to get that with fetch_object()
if possible
Thanks!
use e.g. a $temp
variable
$temp = 0;
while ($row = $Result->fetch_object())
{
$current_value = $row->XYZ; // XYZ is your current value
$difference = $current_value - $temp;
$temp = $current_value;
echo '
<tr>
<td>'.add_date_create($row->stat_AddTime).', '.add_time_create($row->stat_AddTime).'</td>
<td>'.$row->stat_hacks_view.' +('.$row->stat_hacks_view-$row_stat_hacks_view--.')</td>
<td>'.$row->stat_hacks_count.'</td>
<td>'.$row->stat_game_view.'</td>
<td>'.$row->stat_dev_count.'</td>
</tr>
';
}
i don't know where to echo $difference
in your code then, but maybe in the last <td>
...
query with ORDER BY idcolname DESC LIMIT 2