第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 PDO 將圖像從 MySQL 數(shù)據(jù)庫(kù)加載到 Bootstrap carouse

使用 PDO 將圖像從 MySQL 數(shù)據(jù)庫(kù)加載到 Bootstrap carouse

PHP
嗶嗶one 2022-12-11 09:11:29
我正在使用 PDO 將圖像從數(shù)據(jù)庫(kù)插入到 Bootstrap 輪播。我的意思是(加載圖像路徑),但問(wèn)題是當(dāng)我使用fetchall();或fetch獲取所有行值時(shí),如下所示:require_once '..\Config.php';$dbCon = "mysql:host=$host;dbname=$db_name";$conn = new PDO($dbCon, $username, $password);$getquery = $conn->prepare('SELECT (imageurl) FROM special');$getquery->execute();$result = $getquery->fetchall();echo $result['imageurl'];輸出是:Efexor.jpg path upload/17.jpg upload/17.jpg upload/19.jpg upload/18.jpg upload/18.jpg*這是 imageurl 列中的所有行,所以當(dāng)我循環(huán)foreach( $result) 加載從數(shù)據(jù)庫(kù)到 Bootstrap 輪播的圖像。它不起作用<div id="demo" class="carousel slide" data-ride="carousel">  <!-- Indicators -->  <ul class="carousel-indicators">  <?    $i = 0;    foreach($result as $row){        $actives = '';    if($i == 0){        $actives ='active';    }    ?>    <li data-target="#demo" data-slide-to="<?= $i; ?>" class="<?= $actives;?>"></li>    <? $i++ ; }?>  </ul>  <!-- The slideshow -->  <div class="carousel-inner">  <?    $i = 0;    foreach($result as $row){        $actives = '';    if($i == 0){        $actives ='active';    }    ?>    <div class="carousel-item  <?= $actives;?>">      <img src="<?= $row['imageurl']?>">    </div>    <? echo $row['imageurl'];?>    <? $i++; }?>  </div>  <!-- Left and right controls -->  <a class="carousel-control-prev" href="#demo" data-slide="prev">    <span class="carousel-control-prev-icon"></span>  </a>  <a class="carousel-control-next" href="#demo" data-slide="next">    <span class="carousel-control-next-icon"></span>  </a></div>
查看完整描述

1 回答

?
倚天杖

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊

試試這樣:


<!-- The slideshow -->

  <div class="carousel-inner">

  <?

    $i = 0;

   $full_url = 'YOUR URL AND PATH TO IMAGE FOLDER HERE';

    foreach($result as $row){

        $actives = '';

    if($i == 0){

        $actives ='active';

    }

    ?>

    <div class="carousel-item  <?= $actives;?>">

      <img src="<?= $full_url . $row['imageurl']?>">

    </div>

    <? echo $full_url . $row['imageurl'];?>

    <? $i++; }?>

  </div>


查看完整回答
反對(duì) 回復(fù) 2022-12-11
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)