I am working on customise report of a user.In this page I give a option of user check boxes for select data from database.Means user select the data which he wants to see from table.My table have many fields like name , block,contact..and so more. If users wants to see only uid and name only then he check the boxes of name and phone only. my checkboxes are
<form action="#" method="post">
<input type="checkbox" name="check_list[]" value="uid"><label>uid</label>
<input type="checkbox" name="check_list[]" value="name"><label>name</label>
<input type="checkbox" name="check_list[]" value="block"><label>block</label>....and so more
<input type="submit" name="submit" value="Submit"/>
</form>
and php code I am trying is
if(isset($_POST['submit'])){
$sql[] = "select ";
foreach($_POST['check_list'] as $selected){
$sql[]=$selected.',';
}
$sql[]= " from emitra_basic LIMIT 5";
foreach ($sql as $user) {
$ram="$user";
}
if ($result=mysqli_query($conn, $ram))
{
while ($row=mysqli_fetch_row($result))
{
echo "id".$row['uid']."<br/>";
echo "name".$row['name']."<br/>";
}
}
}
But No result.what should i try?
Aucun commentaire:
Enregistrer un commentaire