Here's the data I have fetched from the data base.

```
| Starttime | Stoptime |
| 06:35:00  | 13:05:00 |
| 13:17:00  | 16:38:00 |
| 16:48:00  | 03:07:00 |

```

I have to get the difference of starttime of second row and Stoptime of first row

i.e. `13:17:00-13:05:00 + 16:48:00-16:38:00`

I have written the following code but I couldn't get the result

```
$sql->execute();
$row[]=$sql->fetch();
for($i=0,$j=1,$k=0;$i=count($row[0]);$i++,$j++,$k++){
    $sum += TIMESTAMPDIFF('MINUTE',$row[$j][$i-$k] , $row[$i][$j-$k]);
}

```