I am trying to fetch mysql columns based on user checkbox. This means if user select one checkbox (ex, value2), then retrieve only value2 named colum from table. Is there any way to explicitly specify in mysql select command to retrieve all the user checked values (may be from an array).
<form action="yyy.php" method="post">
<input type="checkbox" name="check_list[]" value="value 1">
<input type="checkbox" name="check_list[]" value="value 2">
<input type="checkbox" name="check_list[]" value="value 3">
<input type="submit" />
</form>
I tried received values in array and used like following, but it doesnt work
<?php
if(!empty($data = $_POST['check_list']))
//cut some parts and simplified to focus on my problem
$sql = "SELECT $data FROM mydata WHERE id='$id'";
?>
In some posts, I noticed using array for the $id like here. Other method may be looping select statement, but I am not sure.
I am not an expert in this field and would like to know any solution [better] solution for this.