That won't work - you would have one select / check parameter per result, so you can't tell where it belongs after you post the (missing) <form>, since all you get is a single $_REQUEST['check'] with value on and a single $_REQUEST['status'] with a value 0, 1 or 2.
Also, $result[id_product] should be {$result['id_product']} etc.
If you name your fields like this, including the product ID, you will be able to know to which product the check and status values apply:
$prod_id = $result['id_product'];
echo "
<select name='status-{$prod_id}' ...>
<input name='check-{$prod_id}' ...>
";
you can then process them server-side like this:
foreach ( $_REQUEST as $k => $v )
if ( preg_match( "@^check-(.*)@", $k, $m ) )
{
$id_product = $m[1];
$status = $_REQUEST[ "status-$id_product" ];
// your INSERT query...
}
or, without preg_match, you'd check if strpos( $k, "check-" ) === 0 and substr( $k, strlen( "check-" ) ) to get the product id.
Alternative: Arrays
PHP offers another way to pass request parameters so that they end up as an array: you can name the inputs a[b], for example:
<input name='a[foo]' value='abc'/>
<input name='a[bar]' value='def'/>
If you submit this form and then
echo "<pre>" . print_r( $_REQUEST, 1 ) . "</pre>";
you will see
Array
(
[a] => Array
(
[foo] => abc
[bar] => def
)
)
That means that you can access those inputs as an array: $_REQUEST['a']['foo'].
You can also do this:
<input name='a[]' value='abc'/>
<input name='a[]' value='def'/>
in which case $_REQUEST is
Array
(
[a] => Array
(
[0] => abc
[1] => def
)
)
The Form
Now let's apply this to your form.
I'm taking this opportunity to introduce you to PDO since mysql_query etc. is deprecated. You could use mysqli, but if you change databases you'd have to change a lot of code; with PDO you'd simply change the connection string.
Also it's wise to use query parameters / parameter binding. The query
"SELECT * FROM PRODUCT WHERE IDCUSTOMER = $_SESSION[IDCUSTOMER]";
has two related problems: First, $_SESSION[IDCUSTOMER] should be {$_SESSION['IDCUSTOMER']}, otherwise you'd get a warning and the query will be ".. WHERE IDCUSTOMER = " - a syntax error.
Second, if $_SESSION['IDCUSTOMER'] is not an integer, the query will also have a syntax error.
// connect to the database (connect.php)
$db = new PDO( "mysql:host=localhost;dbname=your_db", $dbuser, $dbpass );
// query for products using ? placeholders for query parameters:
$sth = $db->prepare( "SELECT * FROM PRODUCT WHERE IDCUSTOMER = ?" );
$sth->execute( [ $_SESSION['IDCUSTOMER'] ] );
while ( $row = $sth->fetch() ) {
$id_product = $result['id_product']; // makes things easier below
echo "
<tr>
<td>
<select name='status[$id_product]'>
<option value='0'>BUY</option>
<option value='1'>SELL</option>
<option value='2'>LOAN</option>
</select>
</td>
<td> $id_product </td>
<td> {$row['name_product']} </td>
<td> <input type='checkbox' name='check[$id_product]' /> </td>
";
}
Here you see we're using the foo[bar] notation for HTTP request parameter names rather than the foo[] notation. This is because if we use <select name='status[]'> and <input type='checkbox' name='check[]'>, then it can happen that count( $_REQUEST['status']) != count( $_REQUEST['check'] ), because a checkbox parameter is only submitted if it is checked, and absent otherwise.
It's also important to use the $result['id_product'] and not simply a row-index ($i++), because the order and number of rows that is returned by the query can change between generating the <form> and submitting it.
Processing the form
This is very similar to the earlier foreach ($_REQUEST snippet, but simpler because we use the foo[bar] syntax for request parameters:
$sth = $db->prepare( "
INSERT INTO PRODUCTS (id_product, name_product, status, IDCUSTOMER ) VALUES (?,?,?,?)
");
foreach ( $_REQUEST['check'] as $id_product => $ignore )
$sth->execute( [
$id_product,
$name_product, // TODO
$status,
$_SESSION['IDCUSTOMER']
] );