By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

Help to improve and/or rip to shreds (constructively) my code

P: n/a
Functions used: in separate included file (Not Mine provided with

function dlookup($table_name, $field_name, $where_condition)
$sql = "SELECT " . $field_name . " FROM " . $table_name . " WHERE " .
return get_db_value($sql);

function get_db_value($sql)
global $db;
$db_look = new DB_Sql();
$db_look->Database = $db->Database;
$db_look->User = $db->User;
$db_look->Password = $db->Password;
$db_look->Host = $db->Host;

return $db_look->f(0);
return "";

I feel that instead of adding A 30+ and growing list of components and then
deleting the ones I want I should just add the ones in i need at the
$Component array contains either null if a component is not to be added or
is a number if an item is to be added its key is equal to fldPartID.

// tblstyle AfterInsert Event begin
$last = mysql_insert_id ();
$CustomerID = DLookup("tblStyle", "fldCustomerID", "fldStyleID=$last");
//Get Std Components For This Customer
$Components = Dlookup("tblcustomer", "fldPartsStdCost",
$StdComponents = unserialize($Components);
$sParams .= $last;
$maxC = count($StdComponents);

$sSQL="INSERT INTO tblorderlines (fldPart,fldPartType,fldStyleID) SELECT
fldPartID, fldPartType, $last FROM tblcomponents;";
for ($i=0; $i<=$maxC; $i++){
$StdCost = $StdComponents{$i};
$sSQL ="UPDATE tblorderlines SET
fldPartCostEstimate='$StdCost',fldRequired=1,fldLi neTotal=fldPartCostEstimat
e Where fldStyleID=$last AND fldPart=$i";
$sSQL="DELETE FROM tblOrderLines WHERE fldStyleID=$last AND fldRequired is
Jul 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.