I have a page with multiple rows and columns.
So, when a user is logged in, if he has any entry in the back end, it should be displayed in front end. Display, if value is 1 in backend table, and should be unchecked if 0 is in back end.
{$i=0}
{foreach from=$last7days item=date}
<tr>
<td><b> {$date}</b><input type='hidden' name='date[]' value ='{$date}'></td>
<td><input type='checkbox' name='BREAKFAST[]' value='1' ><input type='hidden' name='BREAKFAST[]' value='0'></td>
<td><input type='checkbox' name= 'LUNCH[]' value='1'><input type='hidden' name= 'LUNCH[]' value='0'></td>
<td><input type='checkbox' name= 'EVENING[]' value='1'><input type='hidden' name= 'EVENING[]' value='0'></td>
<td><input type='checkbox' name= 'DINNER[]' value='1'><input type='hidden' name= 'DINNER[]' value='0'></td>
<td><input type='checkbox' name= 'MIDNIGHT[]' value='1'><input type='hidden' name= 'MIDNIGHT[]' value='0'></td>
</tr>
{/foreach}
for the php :-
$show_details = mysql_query("select id,user,date,BREAKFAST,LUNCH,EVENING,DINNER,MIDNIGHT,timeUpdate from phpgroupware_new.foodPlan
user='$name'");
table:-
mysql> select * from foodPlan; +----+------------+------------+-----------+-------+---------+--------+----------+---------------------+ | id | user | date | BREAKFAST | LUNCH | EVENING | DINNER | MIDNIGHT | timeUpdate | +----+------------+------------+-----------+-------+---------+--------+----------+---------------------+ | 1 | monisha.md | 2015-03-07 | 1 | 1 | 1 | 1 | 1 | 2015-03-07 11:43:45 | | 2 | monisha.md | 2015-03-08 | 0 | 0 | 0 | 0 | 0 | 2015-03-07 11:43:45 | | 3 | monisha.md | 2015-03-09 | 0 | 0 | 0 | 0 | 0 | 2015-03-07 11:43:45 | | 4 | monisha.md | 2015-03-10 | 0 | 0 | 0 | 0 | 0 | 2015-03-07 11:43:45 | | 5 | monisha.md | 2015-03-11 | 0 | 0 | 0 | 0 | 0 | 2015-03-07 11:43:45 | | 6 | monisha.md | 2015-03-12 | 0 | 0 | 0 | 0 | 0 | 2015-03-07 11:43:45 | | 7 | monisha.md | 2015-03-13 | 0 | 0 | 0 | 0 | 0 | 2015-03-07 11:43:45 | | 8 | admin | 2015-03-07 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | | 9 | admin | 2015-03-08 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | | 10 | admin | 2015-03-09 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | | 11 | admin | 2015-03-10 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | | 12 | admin | 2015-03-11 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | | 13 | admin | 2015-03-12 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | | 14 | admin | 2015-03-13 | 1 | 1 | 0 | 0 | 0 | 2015-03-07 12:35:57 | +----+------------+------------+-----------+-------+---------+--------+----------+---------------------+ 14 rows in set (0.00 sec)