Calvin,
the best way to test this it to output the values of the datarow corresponding to the check box then see if it is "outputting" (for lack of a better word!!) all the values of the selected checkboxes. Deleting the data from tables without actually testing first if it works will make you refill the tables again, quite tedious, as I could imagine!

Scenario.
1. Say you have read/queried data from a table thru a query.
2. The query returns 6 rows and these are displayed in whatever GUI you are using.
3. From the display, your delete/deletion criteria matches rows no# 3, 4 and 5 in the query results displayed  (in 2 abovee)
4. Select the checkboxes matching them, i.e. check boxes at index 2, 3 and 4
5. Display these values first i.e data in the row of the selected checkbox

The trick is, out of the values returned from the query in 2. above, each data row has its primary key (or any unique identifier)
Match the specific UIDs of the displayed data to the selected check box index in a temp store e.g.

LOOP  starts here
    if chechbox is selected
         then dispay_corresponding_value_of_actual_data             //not value of checkbox index
         
         array_of_UIDs[$index]=getSelectedCheckBoxindexValue[$checkboxindex];    // find some way of matching these values!! 
                                                                                                              //e.g in a string array
         
   esle 
        display nothing or do nothing!

From this analogy, your $del_id  = $checkbox[$i]; is wrong. :-) 

You could say, 
LOOP $del_id  = $array_of_UIDs[count_of_selected_checkboxes];  //this is got from the  array_of_UIDs[] size
then obviously delete,  $sql = "update products set product_price = '7.6' where id = $UID_of_data_you_want_2_delete";
end the loop here (to allow for the remaining values in the array_of_UIDs[$index] to be deleted)

Think of it this way, suppose the GUI in which the data displayed was re-arranged, as happens automatically when you click the header label of each column in the display such that they are sorted ascending or descending, the checkbox indexes will change!! using the changed index will delete wrong data!

I hope you get the flow!! Dont be scared to ask again!!

PS: I code in Java but I get the flow of your code, that why my code looks wierd!


On Tue, Aug 31, 2010 at 5:24 PM, Calvin Omari <calvinebarongo@gmail.com> wrote:
Thanks Gregory, I apologize for asking to much, I have tried this code but it is deleting everything

<?php
   
    require 'database.php';
             
    if($_POST['delete']) // from button name="delete"
    {
        $checkbox = $_POST['checkbox']; //from name="checkbox[]"
        $countCheck = count($_POST['checkbox']);
       
        for($i=0;$i<$countCheck;$i++)
        {
            $del_id  = $checkbox[$i];
           
            $sql = "update products set product_price = '7.6' where id = $del_id";
            $result = $mysqli->query($sql) or die(mysqli_error($mysqli));
           
        }
            if($result)
        {   
                header('Location: index.php');
            }
            else
            {
                echo "Error: ".mysql_error();
            }
    }
?>



Thanks alot

On Tue, Aug 31, 2010 at 5:15 PM, Gregory Okoth <gregory.okoth@gmail.com> wrote:
With whatever code, the safest way is to store each value of the table data displayed, (say by Primary key) with a corresponding check box index value, so that whatever check box index is selected, it will point to the exact/same primary key of a datarow, which you will then send to the DB via code for deletion.

Hope it helps!


On Tue, Aug 31, 2010 at 4:30 PM, Calvin Omari <calvinebarongo@gmail.com> wrote:
I will much appreceate

On Tue, Aug 31, 2010 at 4:27 PM, Benjamin <anangwe@gmail.com> wrote:
can i send you a function using select boxes

_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke



--
Our greatest fear is not that we are inadequate,
but that we are powerful beyond measure.
It is our light, not our darkness, that frightens us.

Calvin Omari Systems Developer/Designer
http://www.facebook.com/barongo

_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke


_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke



--
Our greatest fear is not that we are inadequate,
but that we are powerful beyond measure.
It is our light, not our darkness, that frightens us.

Calvin Omari Systems Developer/Designer
http://www.facebook.com/barongo

_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke