I have a form that creates request. By clicking on the 'Create Request' button all the information is added to the 'Requests_Table'. This is working perfectly. Each request has more than one item (at least one)... and each item is comprised of its own characteristics (that's why I want to store this info on a separate table 'SerialNumber_Table'.
So, I need help inserting the Serial number information (Type,Model,Serial number) into 'SerialNumber_Table'. I believe I'll also need to use mysql_insert_id();
to associate each serial number with the correct request_id.
` //Variables for Serial Numbers
$machineType = mysql_prep($_POST['machineType']);
$machineModel = mysql_prep($_POST['machineModel']);
$serialNumber = mysql_prep($_POST['serialNumber']);
<fieldset class="row2">
<h1><?php echo $LANG['hardware_details']; ?></h1>
<p style="margin: 10px 0 10px 0; ">
<p style="margin: 10px 0 10px 0; font-size:12px; padding: 0;"><?php echo $LANG['delete_machines']; ?></p>
<input type="button" value="<?php echo $LANG['add_machines']; ?>" onClick="addRow('dataTable')" style="width: 100px; padding: 2px 5px 2px 5px; background: #e1e1e1; color: #000; font-weight: bold; font-size: 12px; cursor: pointer;" />
<input type="button" value="<?php echo $LANG['remove_machines']; ?>" onClick="deleteRow('dataTable')" style="width: 130px; margin-left: 10px; padding: 2px 5px 2px 5px; background: #e1e1e1; color: #000; font-weight: bold; font-size: 12px; cursor: pointer;" />
</p>
<table id="dataTable" class="form" border="1">
<tbody>
<tr>
<td><input type="checkbox" style=" width: 30px; "/></td>
<td>
<label style="margin-left: 10px;"><?php echo $LANG['machineType']; ?></label>
<input type="text" value="" id="machineType" name="machineType[]" style="width: 70px; margin: 5px 10px 10px 10px; ">
</td>
<td>
<label for="" style="margin-left: 10px;"><?php echo $LANG['machineModel']; ?></label>
<input type="text" value="" id="machineModel" name="machineModel[]" style="width: 70px; margin: 5px 10px 10px 10px;">
</td>
<td>
<label for="" style="margin-left: 10px;"><?php echo $LANG['serialNumbers']; ?></label>
<input type="text" value="" id="serialNumber" name="serialNumber[]" style="width: 120px; margin: 5px 10px 10px 10px;">
</td>
</tr>
</tbody>
</table>
<div class="clear"></div>
</fieldset>
<!-- End Dynamic Forms for Serial Numbers -->
` How could I achieve such a task? If it is any help, I have posted the entire code for this page at http://aerco.com.br/stackoverflow/source.txt
Anyone can point me in the right direction here? Thanks in advance for any thoughts
I could not get what is yout exact need, but for my understanding, You can insert into one table using code and another using MySQL trigger.
Explained over here: http://dev.mysql.com/doc/refman/5.0/en/triggers.html
would the user be the one to supply the serial or is it predefined? this should be the code you need for inserting
$query = "INSERT INTO serialnumber_table(Type,Model,Serial number,request_id) VALUES ($machineType, $machineModel,$serial_number,request_id)
request_id should be gotten from requests table.
if my understanding is correct, insert after this code
$query = "INSERT INTO requests(
request_date, requester_name, requester_email, client_name, client_country, opportunity_number, machine_quantity, severity, specialist, created_by, sales_connect
) VALUES (
'{$request_date}', '{$requester_name}', '{$requester_email}', '{$client_name}', '{$client_country}', '{$opportunity_number}', '{$machine_quantity}', '{$severity}', '{$specialist}', '{$created_by}', '{$sales_connect}'
)";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.