我將如何從我的數據庫中顯示用戶個人資料圖片? (How would I go about displaying user profile pictures from my database?)


問題描述

我將如何從我的數據庫中顯示用戶個人資料圖片? (How would I go about displaying user profile pictures from my database?)

圖片已經在我的數據庫中,我正在嘗試在它們登錄後在窗口右上角的下拉菜單中顯示它們。這是我的網站目前正在做的事情:

enter image description here

右上角突出顯示的藍色部分應該是圖片已顯示,但顯然沒有顯示。但正如您在頁面下方看到的那樣,我的圖片顯示。我不確定為什麼它不會出現在下拉菜單中。我的下拉菜單的代碼在這裡:

<?php
                            include ('core.php');
                            include ('link.php');
                            include ('profile.php');
                            if(isset($_SESSION["steamid"]))
                            {

                            echo'<li class="dropdown">
                                <a href="" class="dropdown‑toggle profile waves‑effect" data‑toggle="dropdown" aria‑expanded=""><img src="'.$steamprofile['avatarfull'].'" alt="user‑img" class="img‑circle"> </a>
                                <ul class="dropdown‑menu">
                                    <li class="notifi‑title">'.$steamprofile['personaname'].'</li>
                                    <li><a href="profile.php"><i class="ti‑user m‑r‑5"></i> Profile</a></li>
                                    <li><a href="usersettings.php"><i class="ti‑settings m‑r‑5"></i> Settings</a></li>
                                    <li><a href="userhistory.php"><i class="ti‑book m‑r‑5"></i> History</a></li>
                                    <li><a href="steamauth/logout.php"><i class="ti‑power‑off m‑r‑5"></i> Logout</a></li>
                                </ul>
                            </li>';

參考解法

方法 1:

you have to put the name of the folder that has the profiles pictures on

<img src='folder/'.$steamprofile['avatarfull'].'' alt="user‑img" class="img‑circle">

方法 2:

  1. Select the url of the photo from the database table

  2. Set a PHP Variable to that url ex.$profileUrl = "URL";

  3. Find the DIV that is your profile image and set the background of the div inside of you HTML/PHP file


  4. </ol>

    BELOW IS STEP 3

    <style>
      .profile {background‑image:url("<?php echo $profileUrl; ?>");}
    </style>
    
    <div class=".profile"></div>

    方法 3:

    You cannot have an echo in an echo:

    echo'<li class="dropdown">
                                        <a href="" class="dropdown‑toggle profile waves‑effect" data‑toggle="dropdown" aria‑expanded=""><img src="'.$steamprofile['avatarfull'].'" alt="user‑img" class="img‑circle"> </a>
                                        <ul class="dropdown‑menu">
                                            <li class="notifi‑title">'. echo $steamprofile['personaname'].'</li>
                                            <li><a href="profile.php"><i class="ti‑user m‑r‑5"></i> Profile</a></li>
                                            <li><a href="usersettings.php"><i class="ti‑settings m‑r‑5"></i> Settings</a></li>
                                            <li><a href="userhistory.php"><i class="ti‑book m‑r‑5"></i> History</a></li>
                                            <li><a href="steamauth/logout.php"><i class="ti‑power‑off m‑r‑5"></i> Logout</a></li>
                                        </ul>
                                    </li>';
    

    Thus, you need to remove the echo in echo $steamprofile['personaname'].

    Your code should be:

    echo'<li class="dropdown">
                                        <a href="" class="dropdown‑toggle profile waves‑effect" data‑toggle="dropdown" aria‑expanded=""><img src="'.$steamprofile['avatarfull'].'" alt="user‑img" class="img‑circle"> </a>
                                        <ul class="dropdown‑menu">
                                            <li class="notifi‑title">'. $steamprofile['personaname'].'</li>
                                            <li><a href="profile.php"><i class="ti‑user m‑r‑5"></i> Profile</a></li>
                                            <li><a href="usersettings.php"><i class="ti‑settings m‑r‑5"></i> Settings</a></li>
                                            <li><a href="userhistory.php"><i class="ti‑book m‑r‑5"></i> History</a></li>
                                            <li><a href="steamauth/logout.php"><i class="ti‑power‑off m‑r‑5"></i> Logout</a></li>
                                        </ul>
                                    </li>';
    

    (by user6150781DecapitatefjoeldesantePanda)

    參考文件

    1. How would I go about displaying user profile pictures from my database? (CC BY‑SA 2.5/3.0/4.0)

#MySQL #Database #PHP #image #display






相關問題

MySQL WHERE 時間戳 >= SUBDATE(MAX(timestamp), INTERVAL 5 DAY) (MySQL WHERE timestamp >= SUBDATE(MAX(timestamp), INTERVAL 5 DAY))

無法連接 - 數據庫或編碼錯誤 (Could Not Connect - Database or Coding Error)

在 MySQL 中查看授權 (View grants in MySQL)

修改列與更改列 (Modify column Vs change column)

SQL 查詢沒有返回任何值 (SQL query did not return any values)

IFNULL trong vấn đề tốc độ mysql (IFNULL in mysql speed issue)

Tối ưu hóa truy vấn MySQL PHP - Phản hồi (MySQL PHP Query Optimization - Feedbacks)

我將如何從我的數據庫中顯示用戶個人資料圖片? (How would I go about displaying user profile pictures from my database?)

自聯接以比較同一張表中的季度數據? (Self join to compare quarterly data from same table?)

設置默認數據庫連接 Mysql Workbench 5.2 (Set Default Database connection Mysql Workbench 5.2)

在 Mac 上將 PHP/MySQL/HTML 生成的報告轉換為 PDF 格式 (Convert reports generated in PHP/MySQL/HTML to PDF format on a Mac)

MYSQL查詢神奇地抓取數值 (MYSQL query magically grabs numeric value)







留言討論