473,412 Members | 3,015 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,412 software developers and data experts.

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_AfterUpdate()
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.OpenRecordset("DISPATCH", 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.OpenRecordset(STRSQL)

TRIPNOV = TRIPNO
If Len(Trim$(CARRIER & vbNullString)) = 0 Then
CARRIER1 = ""
Else
CARRIER1 = CARRIER
End If
If Len(Trim$(BILLTO & vbNullString)) = 0 Then
BILLTOV = ""
Else
BILLTOV = BILLTO
End If
MULTI = "M"
If Len(Trim$(BILLAT & 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.RecordCount
If GRECNUM = 0 Then
rstPICK.Close
rstDISPATCH.Close
dbsDISPATCH.Close
MsgBox "NO TRIPS SAVED"
NOSUC = 1
GoTo C91
End If
rstPICK.MoveFirst
STRTRIP = "[TRIPNO] = " & QUT & Me![TRIPNO] & QUT
rstPICK.FindFirst STRTRIP
If rstPICK.NoMatch Then
rstPICK.MoveLast
rstPICK.Close
rstDISPATCH.Close
dbsDISPATCH.Close
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.Close
dbsDISPATCH.Close
MsgBox "NO PICKUP CITY, SAVE LATER WHEN ALL IS ENTERED"
NOSUC = 1
GoTo C91
End If
If IsNull(rstPICK!STATE) Then
rstPICK.Close
rstDISPATCH.Close
dbsDISPATCH.Close
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!LOADDATE
End If
If IsNull(rstPICK!LOADNO) Then
LOADNOV = ""
Else
LOADNOV = rstPICK!LOADNO
End If
If IsNull(rstPICK!COMMODITY) Then
COMMV = ""
Else
COMMV = rstPICK!COMMODITY
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.MoveNext
Loop
rstPICK.MoveLast
rstPICK.Close

If Len(Trim(FCITY)) > 240 Then
FCITY = Mid(FCITY, 1, 240)
End If
If Len(Trim(SHIPPERV)) > 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.OpenRecordset(STRSQL)

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

rstDROP.MoveFirst
STRTRIP = "[TRIPNO] = " & QUT & Me![TRIPNO] & QUT
rstDROP.FindFirst STRTRIP
If rstDROP.NoMatch Then
rstDROP.MoveLast
rstDROP.Close
rstDISPATCH.Close
dbsDISPATCH.Close
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.Close
dbsDISPATCH.Close
MsgBox "NO DROP CITY, SAVE LATER WHEN ALL IS ENTERED"
NOSUC = 1
GoTo C91
End If
If IsNull(rstDROP!STATE) Then
rstDROP.Close
rstDISPATCH.Close
dbsDISPATCH.Close
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!CONSIGNEE
End If
If IsNull(rstDROP!UNLOADDATE) Then
DDATEV = ""
Else
DDATEV = rstDROP!UNLOADDATE
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!CONSIGNEE
End If
End If
rstDROP.MoveNext
Loop
rstDROP.MoveLast
rstDROP.Close
If Len(Trim(TCITY)) > 240 Then
TCITY = Mid(TCITY, 1, 240)
End If
If Len(Trim(CONSIGNV)) > 240 Then
CONSIGNV = Mid(CONSIGNV, 1, 240)
End If
' ADDING TO DISPATCH
************************************************** *******
GRECNUM = rstDISPATCH.RecordCount
If GRECNUM = 0 Then
rstDISPATCH.Close
dbsDISPATCH.Close
NOSUC = 1
GoTo C91
End If
rstDISPATCH.Index = "TRIPNO"
rstDISPATCH.MoveFirst
rstDISPATCH.Seek "=", TRIPNOV
If rstDISPATCH.NoMatch 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$(PAYOTHER & 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$(LUMPER & 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$(PAYOTHER & 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$(LUMPER & 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.Close
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 1434

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

Similar topics

2
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...
4
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...
0
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...
0
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...
2
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:...
1
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...
0
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...
2
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...
1
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: ...
3
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.