I am trying to write a universal function for several html option elements I have inside a form. The option list will differ for each element so what I want to do is display the options based on the 'id' that references them in my mysql table, this will be an array. The table has 2 columns the first 'id' which is just a number and the second 'prod_option' which is the value I would like displayed. Please can someone explain what is wrong with my code?
This is where I invoke the function inside the select element. I have no problems with the connection.
//This should select 'prod_option' for id's 1,2 & 3 for example
<td><div class="formInput"><label>Cap or Vac:</label>
<select name="pack_req" id="pack_req[]"
value="**<?php $newProd->packRequirements(1,2,3); ?>**" /></select></div></td>
//function in class
public function packRequirements($values){
$con = $this->connection;
$itms = array($values);
$sql = $con->query("SELECT `prod_option`
FROM `packaging_requirements`
WHERE `id` IN('".implode("', '", $itms)."')");
while($r = $sql->fetch_array(MYSQLI_ASSOC)):
echo '<option value="'$itms['prod_option']'"</option>';
endwhile;
}