如何用html中的php连接我的字符串

问题描述 投票:1回答:2

我知道如何连接php变量,但是如果html内的其他脚本是php呢?我用下面的代码:

    $output .='
    <div class="col-md-3 mb-4">
        <div class="card h-100">
          <img class="card-img-top"  src="../admin/upload/'. $row['images'].'" width="50px" height="300px" alt="Image">
          <div class="overlay">
            <p><strong> Title : </strong>'. $row['title'].'</p>
            <p><strong> Author : </strong>'. $row['author'].'</p>
            <p><strong> ISBN : </strong>'. $row['isbn'].'</p>

          </div>
          <div class="card-body">


            '.$status='';
            if ($row ['status'] == 'Available')
            {
              $status='success';
            }
            else if ($row ['status'] == 'Unavailable')
            {
              $status ='danger';
            }.'

<a href="book_details.php?title='. $row['title'].'&isbn='. $row['isbn'].'"> <button type="button"class="btn btn-'.$status.'">'. $row['status'].'</button></a>


          </div>
        </div>

      </div>';

我如何连接我的字符串,尤其是在php if else语句时?感谢您的帮助

php html
2个回答
2
投票

您不能那样做。最干净的解决方案是将if语句before

© www.soinside.com 2019 - 2024. All rights reserved.