hi guys
im beginning in php
im using dream waver and php my admin

i have problem for insert when in insert it give me two record i want to be in same record to insert

for my form :

<table class="table">
<form action="11.php" method="post" name="form2">

    <input type='hidden' name="ORDER_DESC" id='hidden' /> 

<td width>ORDER DESCRIPTION:</td>

    <td class="td"><input type="checkbox" name="checkbox[]" id="checkbox[]" value="CSF"/> CSF  </td>
    <td class="td"><input type="checkbox" name="checkbox[]" id="checkbox[]" value="LFT"/> LFT  </td>
    <td class="td"><input type="checkbox" name="checkbox[]" id="checkbox[]" value="RFR"/> RFR  </td>
    <td class="td"><input type="checkbox" name="checkbox[]" id="checkbox[]" value="TFT"/> TFT  </td>



<td><input type="submit" name="Submit" value="Submit" id="Submit">

i write like this of my php :


$orders = $_POST['checkbox'];
$result = mysql_query ("SELECT orders.staff_id FROM orders
WHERE orders.staff_id = (SELECT staffs.staff_id FROM staffs
WHERE staffs.staff_id = '1000')");
foreach($orders as $key=>$order)

$query="INSERT INTO orders (ORDER_DESC) VALUES ('".$order."' )";
mysql_query($query) or die ('Error Updating the Database' . mysql_errno());
echo "Order Successfully Placed";
echo "No Orders";

can any body help ?

I am not sure what you are trying to accomplish with this code, but in order to update a record you have to use the SQL UPDATE command and specify which records you wish to update (with the WHERE clause) and which fields you wish to populate (with the SET clause).

SELECTing a record from the database does not bring it into memory where you can manipulate it. Each SQL action is discrete in that what you just SELECTed does not influence any future updates or inserts.

In order to copy a record you must first SELECT it, save all of the fields and then specify the saved fields in the new INSERT command.

$result = mysql_query ("SELECT orders.staff_id FROM orders WHERE orders.staff_id = (SELECT staffs.staff_id FROM staffsWHERE staffs.staff_id = '1000')");

What are you trying to do with this code? Retrieve an existing order from the database? For what you have written here you could have used:

$result = mysql_query ("SELECT orders.staff_id FROM orders WHERE orders.staff_id = '1000')");

Since you only specified the staff_id in the SELECT statement all this query will return is 1000. Also, you are not use the result set ($result) anywhere so the results from the query are being lost.