用不同的数据内容php mysql添加每行中的数据

I have a mysql table data. I want to start displaying the data taken from different databases and display as well as the added value of its data based on the value of the data in the first row. Essentially, I want the data values to increase in value in the second row and so on where the value of the data obtained from the sum of the first line, second and so on.

The following is an example of the data output: data output

PHP code:

<?php
$channel=$_GET['channel'];

$sql = mysql_query("SELECT * FROM konten WHERE channel='$channel' ORDER BY id");
$no=1;
while($row=mysql_fetch_row($sql)) {;

    $sqlstart = mysql_query("SELECT * FROM start");
    $barisstart=mysql_fetch_row($sqlstart);
    $wak = strtotime($barisstart['1']);
    $waktuawal = date ("H.i", $wak);


    $dur = $row['7'];
    $durasi = gmdate("H.i", $dur);
    $startawal1 = strtotime(date('Y-m-d').' '.$waktuawal.':00');
    $startakhir1 = strtotime(date('Y-m-d').' '.$durasi.':00');
    $begin_day_unix1 = strtotime(date('Y-m-d').' 00:00:00');
    $jumlah_time1 = date('H.i', ($startawal1 + ($startakhir1 - $begin_day_unix1)));

    echo '<tr>';
        echo '<td align="center"><INPUT type="checkbox" name="chk[]"/></td>';
        echo '<td align="center">'.$no++.'</td>';
        echo '<td align="center" width="10%" hidden>'.$row[0].'</td>';
        echo '<td align="center" width="30">'.$row[2].'</td>';
        echo '<td align="center" width="30">'.$waktuawal.'</td>';
        echo '<td align="center" width="80">'.$durasi.'</td>';
}
?>

I plan in the coding $jumlah_time1 it will be displayed on the second line after $waktuawal is displayed in the first line.

Try an inner join!

http://www.w3schools.com/sql/sql_join_inner.asp

I think this work for you, and try to use pdo or mysqli.