如何显示多个表的字段?

时间:2019-06-27 12:21:07

标签: php html sql

我正在为网站创建搜索表单,我需要知道如何在表中显示联接的字段。

谢谢。

直接link

     $query = "SELECT * FROM partenze a, arrivi b WHERE a.nome_fermata = '$departure' AND b.nome_fermata = '$arrival' AND a.orario >= '$orari' and a.id_tratte=b.id_tratte ORDER BY a.orario ASC";

                    $data = mysqli_query($conn,$query) or die('error');
                    if (mysqli_num_rows($data) > 0) {
                      while ($row = mysqli_fetch_assoc($data)) {

                        //assigns a table field to a variable
                         $id = $row['a.id_tratte'];
                         $departure = $row['a.nome_fermata'];
                         $arrival = $row['b.nome_fermata'];
                         $orario_partenza = $row['a.orario'];
                         $orario_arrivo = $row['b.orario'];

                        ?>
                          <tr>
                            //shows variables
                            <td><?php echo $departure; ?></td>
                            <td><?php echo $arrival; ?></td>
                            <td><?php echo $orario_partenza; ?></td>
                            <td><?php echo $orario_arrivo; ?></td>

                          </tr>
                        <?php

                      }
                    }

0 个答案:

没有答案