admin管理员组

文章数量:1389750

When I run my code, the image is not showing in the admin dashboard, although all other columns (Name, Category, Price, etc.) are displaying correctly. I have already connected the system to the database successfully using PHPMyAdmin, and I can confirm that the data is being fetched properly from the database. The issue seems to be isolated to the image column, as the other product details are being displayed without any problems.

I have checked the image paths in the database, and they appear to be correct, but the images are not displaying in the admin panel.

Additionally, I am experiencing an issue with the alignment of the ID column. When I display the product details in a table, all columns (Name, Category, Price, etc.) are aligned correctly in the center, but the ID column is misaligned and appears to be shifted upwards. However, if I place the ID in the same position as the Name column, the ID column aligns correctly, but the Name column becomes misaligned. It seems like the issue is related to the content inside the cells, particularly the first columns of the table.

Here is the code I am using:

    <thead>
        <tr>
            <?php foreach(array_keys($products[0]) as $title): ?>
            <th scope="col"><?= $title ?></th>
            <?php endforeach  ?>
            <th scope="col">Action</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($products as $product): ?>
        <tr>
            <td><?= htmlspecialchars($product['ID']) ?></td>
            <td><?= htmlspecialchars($product['Name']) ?></td>
            <td><?= htmlspecialchars($product['Genres']) ?></td>
            <td><?= number_format($product['Price'], 2) ?></td>
            <td style="max-width: 200px; word-wrap: break-word; overflow: hidden;">
                    <?= htmlspecialchars($product['Description']) ?>
            </td>
            <td><img src="<?= htmlspecialchars($product['Image']) ?>" alt="Product Image"></td>
            <td>
                <a href="product_edit.php?id=<?= htmlspecialchars($product['ID']) ?>" class="btn edit">
                    <i class="fa-regular fa-pen-to-square"></i>
                </a>
                <a href="product_delete.php?id=<?= htmlspecialchars($product['ID']) ?>" class="btn delete">
                    <i class="fa-solid fa-trash"></i>
                </a>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>

Issues:

Image not displaying: I’ve verified that the image paths stored in the database appear correct, but the images aren't showing up in the table.

ID column misalignment: The ID column shifts upwards, while the Name column misaligns when swapped with ID. All other columns align correctly in the center.

I've tried different approaches for aligning the ID column using CSS, but I haven’t made much progress with the image display issue.

本文标签: Image not showing in admin dashboard of product list (PHP and HTML)Stack Overflow