What are the limitations of using HTML <option> tags in displaying multiple columns of data in a dropdown list in PHP?
When using HTML <option> tags in a dropdown list, it is not possible to display multiple columns of data directly. One way to work around this limitation is to concatenate the columns into a single string and display them as one option. Another approach is to use a custom dropdown menu plugin or create a custom dropdown menu using JavaScript to display multiple columns of data.
<select>
<?php
$data = array(
array("1", "John Doe", "john.doe@example.com"),
array("2", "Jane Smith", "jane.smith@example.com"),
array("3", "Bob Johnson", "bob.johnson@example.com")
);
foreach ($data as $row) {
echo "<option value='" . $row[0] . "'>" . $row[1] . " - " . $row[2] . "</option>";
}
?>
</select>