1

配列からのデータを表示するページがあります。ユーザーが表示された画像の 1 つをクリックすると、別のページにアイテムの詳細を表示する必要があるため、値 $row["Rif"] を保存する必要があります。

私は周りを見ていましたが、Jquery、Ajaxが唯一の利用可能なソリューションのようですが、私はこれらを知りません.

PHPだけで実装する方法はありますか?

ありがとうございました!

 <?php
          if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
                    echo "<div class='col-md-3 col-sm-6 col-xs-12'>
                            <div class='property-container'>
                              <div class='property-image'>
                                <img src='img/img02.jpg' alt='test theme'>
                                <div class='property-price'>
                                  " . $row["DescCom"] . "<br>
                                  <span>" . "€ ". $row["Pre"] . " </span>
                                </div>
                                <div class='property-status'>
                                  <span>" . $row["Rif"] . "</span>
                                </div>
                              </div>
                              <div class='property-features'>
                                <span><i class='fa fa-home'></i> " . $row["Mq"] . " m<sup>2</sup></span>
                                <span><i class='fa fa-hdd-o'></i> " . $row["Cam"] . " Cam</span>
                                <span><i class='fa fa-male'></i> Piano " . $row["Pia"] . " </span>
                              </div>
                              <div class='property-content'>
                                <h3>" . $row["TIP"] . "<small>" . $row["Fra"] . "</small></h3>
                                <button type='submit' name='submit' class='btn btn-default btn-warning btn-xs pull-right btn-dettagli'>Details</button>
                              </div>
                            </div>
                          </div>";
                }
            } else {
                echo '0 results';
            }
            $conn->close();
        ?>
4

1 に答える 1

1

データが保存されていると仮定します$row["Rif"]

<?php
          if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
                    echo "<div class='col-md-3 col-sm-6 col-xs-12'>
                            <div class='property-container'>
                              <div class='property-image'>

 // if this is the image you can hyper-link it to next page that will carry the id as well.

                              <a href='next_page.php?id=". $row['Rif']."><img src='img/img02.jpg' alt='test theme'></a>
                                <div class='property-price'>
                                  " . $row["DescCom"] . "<br>
                                  <span>" . "€ ". $row["Pre"] . " </span>
                                </div>
                                <div class='property-status'>
                                  <span>" . $row["Rif"] . "</span>
                                </div>
                              </div>
                              <div class='property-features'>
                                <span><i class='fa fa-home'></i> " . $row["Mq"] . " m<sup>2</sup></span>
                                <span><i class='fa fa-hdd-o'></i> " . $row["Cam"] . " Cam</span>
                                <span><i class='fa fa-male'></i> Piano " . $row["Pia"] . " </span>
                              </div>
                              <div class='property-content'>
                                <h3>" . $row["TIP"] . "<small>" . $row["Fra"] . "</small></h3>
                                <button type='submit' name='submit' class='btn btn-default btn-warning btn-xs pull-right btn-dettagli'>Details</button>
                              </div>
                            </div>
                          </div>";
                }
            } else {
                echo '0 results';
            }
            $conn->close();
        ?>

これが画像の場合は、ID を含む次のページにハイパーリンクすることができます。

<a href='next_page.php?id=". $row['Rif']."><img src='img/img02.jpg' alt='test theme'></a>
于 2016-02-25T11:44:57.637 に答える