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

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

如何繼續(xù)代碼以允許我單擊圖像并顯示包含更多信息的單獨(dú)頁(yè)面

如何繼續(xù)代碼以允許我單擊圖像并顯示包含更多信息的單獨(dú)頁(yè)面

PHP
UYOU 2021-12-03 19:43:36
截至目前,我可以在單列中顯示我的圖像,包括圖像、標(biāo)題和簡(jiǎn)短描述。所有這些都來(lái)自同一個(gè)數(shù)據(jù)庫(kù)。我不太擅長(zhǎng)編碼,需要一些指導(dǎo),您如何將現(xiàn)有代碼添加到 1) 允許圖片顯示在多列中……以及 2) 允許單擊縮略圖,這將加載一個(gè)單獨(dú)的頁(yè)面,然后我可以在上面設(shè)置樣式并列出完整的食譜。我一直在搞亂代碼,我對(duì)我創(chuàng)建的內(nèi)容感到困惑。我不知道如何繼續(xù)。<h2>index.php:</h2><section class="gallery-links">    <div class="wrapper">        <div class="gallery-container">            <?php            include_once 'includes/dbh.inc.php';            $sql = "SELECT * FROM gallery ORDER BY orderGallery DESC"            $stmt = mysqli_stmt_init($conn);            if (!mysqli_stmt_prepare($stmt, $sql)) {                echo "SQL statment failed!";            } else {                mysqli_stmt_execute($stmt);                    $result = mysqli_stmt_get_result($stmt);                    while ($row = mysqli_fetch_assoc($result)) {                        echo '<a href="#">                        <div style="background-image: url(img/gallery/'.$row["imgFullNameGallery"].');"></div>                        <h3>'.$row["titleGallery"].'</h3>                        <p>'.$row["descGallery"].'</p>                    </a>';                    }            }            ?>        </div>        <?php        echo '<div class="gallery-upload">            <form action="includes/gallery-upload.inc.php" method="post" enctype="multipart/form-data">                <input type="text" name="filename" placeholder="File name...">                <input type="text" name="filetitle" placeholder="Image title...">                <input type="text" name="filedesc" placeholder="Image description...">                <input type="file" name="file">                <button type="submit" name="submit">Upload</button>            </form>        </div>'        ?>    </div></section><h2>gallery-upload.inc.php:</h2><?phpif (isset($_POST['submit'])) {$newFileName = $_POST['filename'];if (empty($newFileName)) {    $newFileName = "gallery";} else {$newFileName = strtolower(str_replace(" ", "-", $newFileName));}$imageTitle = $_POST['filetitle'];$imageDesc = $_POST['filedesc'];
查看完整描述

1 回答

?
一只萌萌小番薯

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

基本上,您需要在anchor標(biāo)簽上創(chuàng)建一個(gè)鏈接,該鏈接將包含url圖像詳細(xì)頁(yè)面,image id如下所示:


    while ($row = mysqli_fetch_assoc($result)) {

        // assuming that imgId is your primary key 

        echo '<a href="detail.php?imageId="'.$row["imgId"].' target="_blank">

            <div style="background-image: url(img/gallery/'.$row["imgFullNameGallery"].');"></div>

            <h3>'.$row["titleGallery"].'</h3>

            <p>'.$row["descGallery"].'</p>

        </a>';

    }

之后,您需要?jiǎng)?chuàng)建一個(gè)新文件detail.php,您可以image id通過(guò)該文件進(jìn)行$_GET['imgId']查詢(xún),然后將能夠獲得完整的圖像詳細(xì)信息。您還需要?jiǎng)?chuàng)建一個(gè)HTML視圖并可以顯示詳細(xì)信息。


希望對(duì)你有幫助?。?/p>


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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