添加一个按钮到PHP

时间:2017-08-21 08:23:49

标签: php jquery html mysql

     while($row = mysqli_fetch_array($result))
     {
      $output .= '
       <tr>
        <td>'.$row["reon"].'</td>
        <td>'.$row["broj_na_tezga"].'</td>
        <td>'.$row["ime"].'</td>
        <td>'.$row["prezime"].'</td>
        <td>'.$row["rok_na_dogovor"].'</td>
        <td>'.$row["duledzija"].'</td>
        <td>'.$row["rez_pau"].'</td>
         //i want to add these buttons but i keep getting an error
        <td>'<a href="update.php?id=<?php echo $row['id'];?>" class="btn btn-success btn-sm">Промени</a>
      <a href="delete.php?id=<?php echo $row['id'];?>" class="btn btn-danger btn-sm">Избриши</a>
      </td>

      '; } echo $output; } else { echo 'Корисникот не постои'; } ?>

<!-- end snippet -->

我是新手,我试图添加按钮,但我得到一个错误确切的&#34;解析错误:语法错误,意外&#39; href&#39; (T_STRING)&#34;请帮助。 TNX

2 个答案:

答案 0 :(得分:0)

这应该适合你:

echo "<td><a href="update.php?id=<?php echo $row['id'];?>" class="btn btn-success btn-sm">Download</a></td>";

答案 1 :(得分:0)

你的语法搞砸了。这应该有效:

<?php

 while($row = mysqli_fetch_array($result))
     {
      $output .= '
       <tr>
        <td>'.$row["reon"].'</td>
        <td>'.$row["broj_na_tezga"].'</td>
        <td>'.$row["ime"].'</td>
        <td>'.$row["prezime"].'</td>
        <td>'.$row["rok_na_dogovor"].'</td>
        <td>'.$row["duledzija"].'</td>
        <td>'.$row["rez_pau"].'</td>
         //i want to add these buttons but i keep getting an error
        <td><a href="update.php?id='.$row['id'].'" class="btn btn-success btn-sm">Промени</a>
      <a href="delete.php?id='.$row['id'].'" class="btn btn-danger btn-sm">Избриши</a>
      </td>

      '; } 
      echo $output; } else { echo 'Корисникот не постои'; } ?>

<!-- end snippet -->