473,804 Members | 3,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to in mysql/php

Expand full for viewing...
I have a parent/child table. The basic setup is as follows:
The parent table is called load sheet. It has fields such as Tripno,
carrier, loaddate, etc.
The child table contains the actual stop offs, in other words the shipper,
load city, load state,

etc. If a pick then shipper, otherwise a consignee.
I have no problem with this parent child table setup. Here's the problem:
I am migrating fom Microsoft Access to a Mysql/PHP setup. From these tables
mentioned above I

currently use vb code to loop through the tables and combine information so
as to add or edit to

a different table all together. This table is called Dispatch. Its sole
purpose is to (at a

glance), see exactly what is going on with what load. Let me explain:
On the dispatch table, I have all information for a pick or drop at a
glance, this might look

like this

tripno loaddate carrier loadfrom more fields----->
123456 04/17/2006 davis trucking abilene, tx / ballinger,tx

As you can see, the load cities from the child table is combined in one
field here.
This loop code snip looks like:

If K = 1 Then
FCITY = rstPICK!CITY & "," & " " & rstPICK!STATE
end if
If K > 1 Then
FCITY = FCITY & " / " & rstPICK!CITY & "," & " " & rstPICK!STATE
end if

The complete MS Access code is below of the load sheet after update event.

Now for the big question, What does this look like in PHP code to accomplish
the same thing????
Say I just entered A main load, and the child records have 2 picks and 3
drops. After entering

the final drop what would I do do generate What code, located where????
If I could get this part done, I have the whole project figured out.

Private Sub Form_AfterUpdat e()
On Error GoTo C91ERR
Dim dbsDISPATCH As Database
Dim rstDISPATCH As Recordset
Dim rstPICK As Recordset
Dim strMessage As String
Set dbsDISPATCH = CurrentDb
Set rstDISPATCH = dbsDISPATCH.Ope nRecordset("DIS PATCH", dbOpenTable)
Dim QUT, STRSQL, STRTRIP
Dim CARRIER1, GRECNUM
Dim FCITY, FSTATE, TCITY, TSTATE
Dim BRATE, CRATE, TDROP
Dim MULTI, BILLTOV, SHIPPERV, CONSIGNV
Dim LDATEV, DDATEV
Dim TRIPNOV, LOADNOV, COMMV
Dim K
QUT = Chr$(34)
STRSQL = "SELECT * FROM PICKUPS ORDER BY PICKUPS.TRIPNO, PICKUPS.PICKNO; "
Set rstPICK = dbsDISPATCH.Ope nRecordset(STRS QL)

TRIPNOV = TRIPNO
If Len(Trim$(CARRI ER & vbNullString)) = 0 Then
CARRIER1 = ""
Else
CARRIER1 = CARRIER
End If
If Len(Trim$(BILLT O & vbNullString)) = 0 Then
BILLTOV = ""
Else
BILLTOV = BILLTO
End If
MULTI = "M"
If Len(Trim$(BILLA T & vbNullString)) = 0 Then
BRATE = 0
Else
BRATE = BILLAT
End If
If Len(Trim$(PAYAT & vbNullString)) = 0 Then
CRATE = 0
Else
CRATE = PAYAT
End If
GRECNUM = rstPICK.RecordC ount
If GRECNUM = 0 Then
rstPICK.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
MsgBox "NO TRIPS SAVED"
NOSUC = 1
GoTo C91
End If
rstPICK.MoveFir st
STRTRIP = "[TRIPNO] = " & QUT & Me![TRIPNO] & QUT
rstPICK.FindFir st STRTRIP
If rstPICK.NoMatch Then
rstPICK.MoveLas t
rstPICK.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
NOSUC = 1
GoTo C91
End If
K = 0
Do Until rstPICK.EOF
K = K + 1
If rstPICK!TRIPNO <> TRIPNOV Then Exit Do
If IsNull(rstPICK! CITY) Then
rstPICK.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
MsgBox "NO PICKUP CITY, SAVE LATER WHEN ALL IS ENTERED"
NOSUC = 1
GoTo C91
End If
If IsNull(rstPICK! STATE) Then
rstPICK.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
MsgBox "NO PICKUP STATE, SAVE LATER WHEN ALL IS ENTERED"
NOSUC = 1
GoTo C91
End If
If K = 1 Then
FCITY = rstPICK!CITY & "," & " " & rstPICK!STATE
If IsNull(rstPICK! SHIPPER) Then
SHIPPERV = ""
Else
SHIPPERV = rstPICK!SHIPPER
End If
If IsNull(rstPICK! LOADDATE) Then
LDATEV = ""
Else
LDATEV = rstPICK!LOADDAT E
End If
If IsNull(rstPICK! LOADNO) Then
LOADNOV = ""
Else
LOADNOV = rstPICK!LOADNO
End If
If IsNull(rstPICK! COMMODITY) Then
COMMV = ""
Else
COMMV = rstPICK!COMMODI TY
End If
End If
If K > 1 Then
FCITY = FCITY & " / " & rstPICK!CITY & "," & " " & rstPICK!STATE

If IsNull(rstPICK! SHIPPER) Then
SHIPPERV = SHIPPERV
Else
SHIPPERV = SHIPPERV & " / " & rstPICK!SHIPPER
End If
End If
rstPICK.MoveNex t
Loop
rstPICK.MoveLas t
rstPICK.Close

If Len(Trim(FCITY) ) > 240 Then
FCITY = Mid(FCITY, 1, 240)
End If
If Len(Trim(SHIPPE RV)) > 240 Then
SHIPPERV = Mid(SHIPPERV, 1, 240)
End If

' DROPS *************** *************** *************** *************** *****

Dim rstDROP As Recordset
STRSQL = "SELECT * FROM DROPS ORDER BY DROPS.TRIPNO, DROPS.DROPNO;"
Set rstDROP = dbsDISPATCH.Ope nRecordset(STRS QL)

GRECNUM = rstDROP.RecordC ount
If GRECNUM = 0 Then
rstDROP.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
MsgBox "NO TRIPS SAVED"
NOSUC = 1
GoTo C91
End If

rstDROP.MoveFir st
STRTRIP = "[TRIPNO] = " & QUT & Me![TRIPNO] & QUT
rstDROP.FindFir st STRTRIP
If rstDROP.NoMatch Then
rstDROP.MoveLas t
rstDROP.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
NOSUC = 1
GoTo C91
End If
K = 0
Do Until rstDROP.EOF
K = K + 1
If rstDROP!TRIPNO <> TRIPNOV Then Exit Do
If IsNull(rstDROP! CITY) Then
rstDROP.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
MsgBox "NO DROP CITY, SAVE LATER WHEN ALL IS ENTERED"
NOSUC = 1
GoTo C91
End If
If IsNull(rstDROP! STATE) Then
rstDROP.Close
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
MsgBox "NO DROP STATE, SAVE LATER WHEN ALL IS ENTERED"
NOSUC = 1
GoTo C91
End If
If K = 1 Then
TCITY = rstDROP!CITY & "," & " " & rstDROP!STATE

If IsNull(rstDROP! CONSIGNEE) Then
CONSIGNV = ""
Else
CONSIGNV = rstDROP!CONSIGN EE
End If
If IsNull(rstDROP! UNLOADDATE) Then
DDATEV = ""
Else
DDATEV = rstDROP!UNLOADD ATE
End If
End If
If K > 1 Then
TCITY = TCITY & " / " & rstDROP!CITY & "," & " " & rstDROP!STATE
If IsNull(rstDROP! CONSIGNEE) Then
CONSIGNV = CONSIGNV
Else
CONSIGNV = CONSIGNV & " / " & rstDROP!CONSIGN EE
End If
End If
rstDROP.MoveNex t
Loop
rstDROP.MoveLas t
rstDROP.Close
If Len(Trim(TCITY) ) > 240 Then
TCITY = Mid(TCITY, 1, 240)
End If
If Len(Trim(CONSIG NV)) > 240 Then
CONSIGNV = Mid(CONSIGNV, 1, 240)
End If
' ADDING TO DISPATCH
*************** *************** *************** ************
GRECNUM = rstDISPATCH.Rec ordCount
If GRECNUM = 0 Then
rstDISPATCH.Clo se
dbsDISPATCH.Clo se
NOSUC = 1
GoTo C91
End If
rstDISPATCH.Ind ex = "TRIPNO"
rstDISPATCH.Mov eFirst
rstDISPATCH.See k "=", TRIPNOV
If rstDISPATCH.NoM atch Then
With rstDISPATCH
..AddNew ' Add new record.
If CARRIER1 = "" Then
!CARRIER = Null
Else
!CARRIER = CARRIER1
End If

!TRIPNO = TRIPNOV
!SM = MULTI
If BILLTOV = "" Then
!BILL_TO = Null
Else
!BILL_TO = BILLTOV
End If
If SHIPPERV = "" Then
!SHIPPER = Null
Else
!SHIPPER = SHIPPERV
End If
If FCITY = "" Then
!CITY_LD = Null
Else
!CITY_LD = FCITY
End If
If CONSIGNV = "" Then
!CONSIGNEE = Null
Else
!CONSIGNEE = CONSIGNV
End If
If LDATEV = "" Then
!LOAD_DATE = Null
Else
!LOAD_DATE = LDATEV
End If
If DDATEV = "" Then
!DEL_DATE = Null
Else
!DEL_DATE = DDATEV
End If
If COMMV = "" Then
!COMMODITY = Null
Else
!COMMODITY = COMMV
End If
If LOADNOV = "" Then
!LOADNO = Null
Else
!LOADNO = LOADNOV
End If

If TCITY = "" Then
!CITY_DEL = Null
Else
!CITY_DEL = TCITY
End If
If CRATE = 0 Then
!PAYAT = Null
Else
!PAYAT = CRATE
End If
If Len(Trim$(PAYOT HER & vbNullString)) = 0 Then
!PAYOTHER = Null
Else
!PAYOTHER = PAYOTHER
End If
If Len(Trim$(DROP & vbNullString)) = 0 Then
!PK_DRP = Null
Else
!PK_DRP = DROP
End If
If Len(Trim$(LUMPE R & vbNullString)) = 0 Then
!LUMPER = Null
Else
!LUMPER = LUMPER
End If
!TOTALPAY = Nz(PAYAT) + Nz(PAYOTHER) + Nz(DROP) + Nz(LUMPER)

If Len(Trim$(NOTES & vbNullString)) = 0 Then
!NOTES = Null
Else
!NOTES = NOTES
End If
..Update ' Save changes.
..Close
End With
Else
With rstDISPATCH
' EDIT DISPATCH *************** *************** *************** ***************
..Edit
If CARRIER1 = "" Then
!CARRIER = Null
Else
!CARRIER = CARRIER1
End If
'!CARRIER = CARRIER1
!TRIPNO = TRIPNOV
!SM = MULTI
If BILLTOV = "" Then
!BILL_TO = Null
Else
!BILL_TO = BILLTOV
End If
If SHIPPERV = "" Then
!SHIPPER = Null
Else
!SHIPPER = SHIPPERV
End If
If FCITY = "" Then
!CITY_LD = Null
Else
!CITY_LD = FCITY
End If
If CONSIGNV = "" Then
!CONSIGNEE = Null
Else
!CONSIGNEE = CONSIGNV
End If
If LDATEV = "" Then
!LOAD_DATE = Null
Else
!LOAD_DATE = LDATEV
End If
If DDATEV = "" Then
!DEL_DATE = Null
Else
!DEL_DATE = DDATEV
End If
If COMMV = "" Then
!COMMODITY = Null
Else
!COMMODITY = COMMV
End If
If LOADNOV = "" Then
!LOADNO = Null
Else
!LOADNO = LOADNOV
End If
If TCITY = "" Then
!CITY_DEL = Null
Else
!CITY_DEL = TCITY
End If
If CRATE = 0 Then
!PAYAT = Null
Else
!PAYAT = CRATE
End If
If Len(Trim$(PAYOT HER & vbNullString)) = 0 Then
!PAYOTHER = Null
Else
!PAYOTHER = PAYOTHER
End If
If Len(Trim$(DROP & vbNullString)) = 0 Then
!PK_DRP = Null
Else
!PK_DRP = DROP
End If
If Len(Trim$(LUMPE R & vbNullString)) = 0 Then
!LUMPER = Null
Else
!LUMPER = LUMPER
End If
!TOTALPAY = Nz(PAYAT) + Nz(PAYOTHER) + Nz(DROP) + Nz(LUMPER)
If Len(Trim$(NOTES & vbNullString)) = 0 Then
!NOTES = Null
Else
!NOTES = NOTES
End If
..Update ' Save changes.
..Close
End With
End If
'************** *************** *******
dbsDISPATCH.Clo se
C91:
If FIRLOAD = 0 Then FIRLOAD = 1
TRIPNO.Locked = True
If NOSUC = 1 Then
Call NOSUCCES
End If
Exit Sub
C91ERR:
MsgBox "AN AFTER UPDATE ERROR OCCURRED"
Resume

End Sub
Apr 16 '06 #1
0 1454

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

Similar topics

2
10291
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py clean # python setup.py build running build running build_py
4
1305
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I can not seem to get any of the functions working on it. So I have now dopwnloaded the latest version hoping that this will fix the error. I have managed to install the MySQL-shared-compat-4.0.1-0.i386.rpm but
0
1471
by: Yun Guan | last post by:
Hello mysql gurus, I am trying to run perl on mysql database on Red Hat box. I want to install DBI and DBD:mysql using CPAN: perl -MCPAN -e shell cpan>install DBI The above succeeded, but cpan>install DBD::mysql
0
3952
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
2
2367
by: Saqib Ali | last post by:
I installed mySQL and have it running.... but I think I made a mistake somewhere along the line...... I believe I did follow the instructions that were provided with the distribution at: http://dev.mysql.com/downloads/ The database is up. It seems that a test database instance has been created (named "test"). I can see it. However, the other database instance that should have been created, named "mysql" doesn't show up when I do "show...
1
3827
by: Alex Hunsley | last post by:
I am trying to install the DBD::mysql perl module. However, it claims I need mysql.h: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /home/alex/.cpan/Metadata Database was generated on Mon, 29 Nov 2004 16:01:05 GMT Running install for module DBD::mysql Running make for R/RU/RUDY/DBD-mysql-2.9004.tar.gz CPAN: Digest::MD5 loaded ok
0
1887
by: ./Rob & | last post by:
Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via CURRENT_USER().) Here it is, line-by-line. Inline comments are denoted by '//'
2
2908
by: trihanhcie | last post by:
I m currently working on a Unix server with a fedora 3 as an os My current version of mysql is 3.23.58. I'd like to upgrade the version to 5.0.18. After downloading from MYSQL.COM the package on the site, I made : rpm -i MySQL-server-5.0.18-0.i386.rpm then i have errors that relate to many conflicts. I cannot figure out why -and- cannot upgrade. Please Help !
1
3229
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: warning: MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5 file /etc/my.cnf from install of MySQL-server-standard-5.0.24a-0.rhel3 conflicts with file from package mysql-3.23.58-1 file...
3
8833
by: menzies | last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a successful 'sudo make install.' Before every attempt I even do a sudo make distclean to make sure I haven't gotten things mucked up from a prior attempt. OS: Mac OS X 10.4.10 MySQL: v5.0.41 for Mac OSX-i686 DBI: v1.58 (installed fine using CPAN)...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2988
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.