
Originally Posted by
Kalon
the naming system you used will probably still be ok but imho will make your php code trickier.
I would have done it this way.
Going back to your image of checkboxes in post 1, I would have given the 4 checkboxes for each ID the same name and the value of each checkbox for an id set to the column name it represents in the database. This way, the array of checked check boxes for each id will contain the column names you want to update.
So for ID = 1, I would do this
Code:
<input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakIndex" checked="checked"/>
<input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakHot" checked="checked"/>
<input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakNew" checked="checked"/>
<input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakAktiv" />
and then similarly for each 4 checkboxes for the other ID's
Then you can loop through each array of checkboxes to see which column names were checked and you can then build your update query with those column names.
This is the problem...that i don't have a clue how to do it
since i'm new on php.
My Php script looks like this now:
PHP Code:
<span class="result_column" style="width: 7%;"><center><input type="checkbox" style="checkbox" name="chk_id_'.$row['PakID'].'[]" value="PakIndex" '.$checkedindex.'/></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_'.$row['PakID'].'[]" value="PakHot" '.$checkedhot.'/></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_'.$row['PakID'].'[]" value="PakNew" '.$checkednew.'/></center></span>
<span class="result_column" style="width: 8%;"><center><input type="checkbox" style="checkbox" name="chk_id_'.$row['PakID'].'[]" value="PakAktiv" '.$checkedaktiv.'/></center></span>
and html code looks like his:
HTML Code:
<span class="result_column" style="width: 7%;"><center><input type="checkbox" style="checkbox" name="chk_id_4[]" value="PakIndex" checked="checked"/></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_4[]" value="PakHot" checked="checked"/></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_4[]" value="PakNew" checked="checked"/></center></span>
<span class="result_column" style="width: 8%;"><center><input type="checkbox" style="checkbox" name="chk_id_4[]" value="PakAktiv" /></center></span>
<br/>
<span class="result_column" style="width: 7%;"><center><input type="checkbox" style="checkbox" name="chk_id_3[]" value="PakIndex" checked="checked"/></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_3[]" value="PakHot" checked="checked"/></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_3[]" value="PakNew" checked="checked"/></center></span>
<span class="result_column" style="width: 8%;"><center><input type="checkbox" style="checkbox" name="chk_id_3[]" value="PakAktiv" /></center></span>
<br />
<span class="result_column" style="width: 7%;"><center><input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakIndex" /></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakHot" /></center></span>
<span class="result_column" style="width: 6%;"><center><input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakNew" /></center></span>
<span class="result_column" style="width: 8%;"><center><input type="checkbox" style="checkbox" name="chk_id_1[]" value="PakAktiv" /></center></span>
Thank you!
Bookmarks