简体   繁体   中英

Image not displaying on select option using php

I have a form which is supposed to show users with their uploaded images on the right of their names. I have uploaded their images using:

require 'db.php';
if (isset($_POST['submit']))
{
    $target_dir = "uploads/";
    $num=rand(1000000,10000000);
    $target_file = $target_dir ."$num". basename($_FILES["photo"]["name"]);
    $target_file = $target_dir . basename($_FILES["photo"]["name"]);
    move_uploaded_file($_FILES["photo"]["tmp_name"], $target_file);
    extract($_POST);
$result=mysqli($conn, $sql);
    }

Below is the code that would display users' image together with their name:

<option value="<?php echo $rowUser['id']; ?>"><?php echo "<img src='uploads/".$rowUser['photo']."' >";?><?php echo $rowUser['name']; ?></option>

The images wouldn't display on coming to the users page. Only the name would come up. Am willing to learn and open to any solution you might have. Thanks

The image is not displayed because <option> is allowed to contain text only , possibly with escaped characters (like &eacute; ).

If you would like your options to contain images in it, you should use a JS solution like selectize . Such libraries solve the problem by creating something that behaves like a select control with options, but it's actually made of divs and spans .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM