I have this code. I have a table new-space includes four fields(drive, wikis, task, chat).database connection is OK. Every fields has only value 0 or 1. I want to show those field has value 1. I don't know what will be query. Any kind of help will be appreciated.
$conn = mysqli_connect('localhost', 'root', '', 'hello');
First:SeLECT the field using query where value=1
$sql="SELECT * from table_name Where values='1'";
And
Display content using mysql_fetch_array function.
try this
$sql = "SELECT * FROM `new-space`";
$data = $conn->query($sql);
while($row = $data->fetch_assoc()) {
$result[] = $row["drive"] == 1 ? 'drive':null;
$result[] = $row["wikis"] == 1 ? 'wikis':null;
$result[] = $row["task"] == 1 ? 'task':null;
$result[] = $row["chat"] == 1 ? 'chat':null;
}
print_r(array_filter($result));