Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you edit multiple drop down menus
    text
    copied!<p>I have a drop down menu that I can edit just fine;</p> <pre><code> // Connect to Local Host @ $db=mysqli_connect('localhost', 'root'); if (!$db) { do_Warning(-1); exit; } // Connect to Database @ mysqli_select_db($db,'coshh'); echo '&lt;tr&gt;&lt;td&gt;Harmful effects:&lt;/td&gt; &lt;td&gt;&lt;select name="Harmful_effects"&gt;&lt;option&gt;&lt;/option&gt;'; /* Create SQL to extract effects options */ $sql = "SELECT * FROM `lookup_harmful_to_reproductive_system` ORDER BY `id`"; /* Perform SQL to get effects options */ $result = mysqli_query($db, $sql); /* Build dropdown list for each effects option found in result */ while ($row=mysqli_fetch_array($result,MYSQLI_BOTH)) { echo '&lt;OPTION value="'.$row['Harmful_effects'].'"'; if ($Harmful_effects == $row['Harmful_effects']) { echo ' selected'; } echo '&gt;'.$row['Harmful_effects'].'&lt;/OPTION&gt;'; } echo '&lt;/select&gt;&lt;/select&gt;&lt;/td&gt;'; </code></pre> <p>However, I've been asked to change it to a multiple option drop down menu, which I have done and it inserts multiple options into my MySQL database. The big problem I've encountered is that when you go to edit this multiple drop down menu it doesn't highlight the previously selected/entered data from the database. I've made a start but I'm really struggling to get me head around it;</p> <pre><code>echo '&lt;tr&gt;&lt;td&gt;Harmful effects:&lt;/td&gt; &lt;td&gt;&lt;select name="Harmful_effects[]" multiple="multiple" STYLE="width: 500px" size="0"&gt;&lt;option&gt;&lt;/option&gt;'; /* Create SQL to extract effects options */ $sql = "SELECT * FROM `lookup_harmful_to_reproductive_system` ORDER BY `id`"; /* Perform SQL to get effects options */ $result = mysqli_query($db, $sql); /* Build dropdown list for each effects option found in result */ while ($row=mysqli_fetch_array($result,MYSQLI_BOTH)) { echo '&lt;OPTION value="'.$row['Harmful_effects'].'"'; if ($Harmful_effects == $row['Harmful_effects']) { echo ' selected'; } echo '&gt;'.$row['Harmful_effects'].'&lt;/OPTION&gt;'; } echo '&lt;/select&gt;&lt;/select&gt;&lt;/td&gt;'; </code></pre> <p>Any suggestions/help will be much appreciated! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload