473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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

Functions used: in separate included file (Not Mine provided with
codecharge)

function dlookup($table_name, $field_name, $where_condition)
{
$sql = "SELECT " . $field_name . " FROM " . $table_name . " WHERE " .
$where_condition;
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;

$db_look->query($sql);
if($db_look->next_record())
return $db_look->f(0);
else
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
start.
$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",
"fldCustomerID=$CustomerID");
$StdComponents = unserialize($Components);
$sParams .= $last;
$maxC = count($StdComponents);

$sSQL="INSERT INTO tblorderlines (fldPart,fldPartType,fldStyleID) SELECT
fldPartID, fldPartType, $last FROM tblcomponents;";
$db->query($sSQL);
for ($i=0; $i<=$maxC; $i++){
$StdCost = $StdComponents{$i};
if($StdCost>0){
$sSQL ="UPDATE tblorderlines SET
fldPartCostEstimate='$StdCost',fldRequired=1,fldLi neTotal=fldPartCostEstimat
e Where fldStyleID=$last AND fldPart=$i";
$db->query($sSQL);
}
}
$sSQL="DELETE FROM tblOrderLines WHERE fldStyleID=$last AND fldRequired is
null";
$db->query($sSQL);
Jul 16 '05 #1
0 1577

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
2
by: Paul H | last post by:
My customer has an ecommerce store. He receives approx 600 orders per month. Worldpay.com handles the credit card transactions and sends my customer an email for each order containing the...
2
by: Foodbank | last post by:
Hi everyone, I'm having trouble implementing a supposedly simple Least Significant Digit first Radix Sort. The book I'm using gave me somewhat of a template that I touched up (below), but I'm...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
8
by: Steven C. Liu | last post by:
Hi, I am trying to compile a C program that I found on the Internet; I want to use it to spoof my hostid on a Linux box. The code is here: ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
62
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which...
11
by: Peted | last post by:
Im using c# 2005 express edition Ive pretty much finished an winforms application and i need to significantly improve the visual appeal of the interface. Im totaly stuck on this and cant seem...
3
by: Brad | last post by:
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and response.binarywrite to send content to the browser. This has worked great for years...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.