Skip to content

Create edit type "select" options manually from SQL query


Code snippet:

$results = mysqli_query('SELECT ID, COUNTRY FROM tblCountry');
$select_kv = '';  
if ($results) {
  while($row = mysql_fetch_array($result)) {
    $select_kv .= $row['ID'] .':'. $row['COUNTRY'] .';';
  }
}

$dg-> set_col_edittype('COUNTRY_ID', 'select', ':;'. $select_kv);

Optional:
Add ":;" (without surrounding quotes) to the be beginning of the string to also get the blank value as the top option.


Feedback and Knowledge Base