将while($ data = mysqli_fetch_assoc($ sql))更改为PDO

时间:2017-04-05 18:12:40

标签: php mysql pdo

所以我有这段代码:

<div class="row">
<?php
$sql = $koneksi->prepare("SELECT * FROM lapangan ORDER BY id_lap DESC");
if($sql->rowCount() == 0){
    echo "There is no product!";
}else{
    while($data = mysqli_fetch_assoc($sql)){
                ?>
            <div class="span4">
                <div>
                <table>
                <tr>
                <td>
                    <img src="<?php echo $data['lap_img']; ?>" style="max-width: 300px" />
                        <div style="max-width: 300px">
                            <ul data-role="listview" data-inset="true">
                            <li data-role="list-divider" data-theme="a"><?php echo $data['lap_name']; ?></li>
                            <li><p><?php echo $data['lap_ket']; ?></p></li>
                            </ul>
                        </div>
                </td>
                </tr>
                <tr>
                <td>
                    <a href="detail.php?id_lap=<?php echo $data['id_lap'];?>" data-theme="a" data-iconpos="notext" data-role="button">Detail</a>
                    <a href="detail.php?id_lap=<?php echo $data['id_lap'];?>" data-theme="g" data-iconpos="notext" data-role="button">Lokasi</a>
                </td>
                </tr>
                </table>
                <hr>
                </div>
            </div>
            <?php   
          }
          }

          ?>
        </div>

我想将mysqli_fecth_assoc更改为PDO。我已经搜索了一些教程,它没有给我一个答案(也许,因为它使用循环?)。任何人都可以帮助我吗?

0 个答案:

没有答案