在php中的回声表并导致php

时间:2014-05-11 17:14:44

标签: php

我正在进行实时搜索,它工作正常,问题是我无法以我想要的格式回应它,有人可以帮助,

  while($r=mysqli_fetch_array($q))
     {
    $title = $r["Title"];
    $profile = $r["Tag"];

    echo '<div class="result"><table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th>Title</th>
                  <th>Year</th>
                  <th>Cast</th>
                  <th>Tags</th>
                </tr>
              </thead>
              <tbody>        
              <?php

    $sql = 'SELECT * FROM movie ORDER BY MovieID DESC';
                 $r = @mysqli_query ($dbc, $sql);
                 while ($row= mysqli_fetch_array($r)){
                        echo '<tr>';
                        echo '<td>'. $row['Title'] . '</td>';
                        echo '<td>'. $row['YEAR'] . '</td>';
                        echo '<td>'. $row['Cast'] . '</td>';
                        echo '<td>'. $row['Tag'] . '</td>';
                        echo '<td width=250>';
                        echo '<a class="btn" href="read.php?id='.$row['MovieID'].'">View</a>';
                        echo ' ';
                        echo '<a class="btn btn-success" href="update.php?id='.$row['MovieID'].'">Edit</a>';
                        echo ' ';
                        echo '<a class="btn btn-danger" href="delete.php?id='.$row['MovieID'].'">Delete</a>';
                        echo '</td>';
                        echo '</tr>';
               }

              ?>
              </tbody>
          </table>






              </div>';

有人可以提供帮助,因为它不会显示我的结果

2 个答案:

答案 0 :(得分:0)

你需要在第一个echo之后关闭单引号。试试这个

<?php
  while($r=mysqli_fetch_array($q))
     {
    $title = $r["Title"];
    $profile = $r["Tag"];

    echo '<div class="result"><table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th>Title</th>
                  <th>Year</th>
                  <th>Cast</th>
                  <th>Tags</th>
                </tr>
              </thead>
              <tbody>';      


    $sql = 'SELECT * FROM movie ORDER BY MovieID DESC';
                 $r = @mysqli_query ($dbc, $sql);
                 while ($row= mysqli_fetch_array($r)){
                        echo '<tr>';
                        echo '<td>'. $row['Title'] . '</td>';
                        echo '<td>'. $row['YEAR'] . '</td>';
                        echo '<td>'. $row['Cast'] . '</td>';
                        echo '<td>'. $row['Tag'] . '</td>';
                        echo '<td width=250>';
                        echo '<a class="btn" href="read.php?id='.$row['MovieID'].'">View</a>';
                        echo ' ';
                        echo '<a class="btn btn-success" href="update.php?id='.$row['MovieID'].'">Edit</a>';
                        echo ' ';
                        echo '<a class="btn btn-danger" href="delete.php?id='.$row['MovieID'].'">Delete</a>';
                        echo '</td>';
                        echo '</tr>';
               }


        echo
        '</tbody>
          </table>
       </div>';
 ?>

答案 1 :(得分:0)

首先: 你为什么在第一个回声中使用<?php

将其替换为结束';,一切都应该正常。