dongou5100 2017-01-03 04:15
浏览 59

用不同的数据内容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.

  • 写回答

1条回答 默认 最新

  • drbfxb977777 2017-01-03 04:23
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据