0

The situation is very simple and find this weird why i fail to insert an image after each result in my combobox (dropdown menu).

I am trying to insert $image here!.

       <select name = 'pSelect' id = 'pSelect'>       
      <?php

        $result = mysql_query
        ("                    
            SELECT ID, Project, Projectnummer, Klant
            FROM tblproject
            WHERE Status = '1'
            ORDER BY Klant ASC
        ");

         $image = "<img src='images/status_groen.png' width='15' height='15' /> ";

        while($row1 = mysql_fetch_array($result))
           {
                $pID = $row1['ID'];

                echo "<option value=\"" . $row1['ID'] . "\"";

                if (isset($_POST['pSelect']) &&  $row1['ID'] == $_POST['pSelect']) 
                { 
                echo " selected='selected'"; 
                } 

                echo ">" . $row1['Klant'] ." ". $row1['Project'] ." ". $row1['Projectnummer'] ." ".$image. "</option>";

                echo "<br/>'";
           }

        ?>
    </select>

after data output it shows the image syntax in red, indicating it might be a syntax problem but not necessarely.

Source output:

 <option value="202">3DNL reCAPTCHA toevoegen 13097/1 <img src='images/status_groen.png' width='15' height='15'/> </option><br/>

1 Answers1

0

The only thing I can see there is that your img tag is not closed with

'/>'

EDIT

I didn't know that, but option tag supports only text

this was a known issue and it was answered on this thread

Community
  • 1
  • 1
theLibertine
  • 175
  • 7
  • Have added the slash indeed, you were right, but it did not fix the problem unfortunatly. I have tested the images with an echo further on in my code, still no idea how to insert an image in a dropdown menu without adding it as a longblob in a database. – DragonChaser Sep 23 '13 at 12:47
  • What do you see in the generated HTML? – theLibertine Sep 23 '13 at 13:21
  • Good question, adding source output right now, it shows the image is indeed red, yet it is a good indication but not 100% there yet. I do have the feeling i am missing something here. – DragonChaser Sep 23 '13 at 13:28
  • any possibility of it implementing in a select2 github drop down menu? (jquery). i somehow need to fix this anyway sinds its the most efficient way of displaying information in my projects. Kind of stupid its not possible.... i guess we all can aggree on this one. Anywayz tnx, will click solved if no replies will come in @theLibertine. – DragonChaser Sep 23 '13 at 14:15
  • In the thread I linked there is a jquery plugin that may be a possible solution. Try [http://www.marghoobsuleman.com/jquery-image-dropdown] – theLibertine Sep 23 '13 at 15:22
  • Am figuring out how to do this with html css and php instead of going all jquery because it would not work with my current construction. I have been somewhat succesfull over the night. Tnx for providing the information! i will not give up!. – DragonChaser Sep 24 '13 at 07:27