Take the 2-minute tour ×

I'm really struggling with how I can get this to work, basically I have an option where you can add a fixed fare as follows: (fixed fare ID will be made hidden)

enter image description here

Which needs to be added into the following two tables:


enter image description here


enter image description here

For tblfixedfare, when a user adds a fixed fare it would need to insert two entries into the database. Considering the database as it is, the next example would be:

  • ID: 7, FixedFareID: 4, DayHalf: 1, Fare: 'Day Time Fare' value
  • ID: 8, FixedFareID: 4, DayHalf: 2, Fare: 'Night Time Fare' value

For tblfixedfaresetup, at the same time another two inserts need to be made to this database. Considering the database as it is, the next example would be:

  • ID: 8, FixedFareID: 4, ShortPostCode: 'To Postcode' value, Leg: 1, LegCount: 2
  • ID: 9, FixedFareID: 4, ShortPostCode: 'From Postcode' value, Leg: 2, LegCount: 2

** Note, LegCount would always = 2

If anybody could provide any help with this, it would be much appreciated. (I am using prepared statements using PDO)


How would I go about inserting the FixedFareID, it would need to look at the highest value in the FixedFareID and add 1. So for tblfixedfare, the next FixedFareID value would need to be 4, any ideas how I can implement this?

share|improve this question
What have you tried? –  Aleks G Oct 10 '12 at 9:58
So what is now the question? –  Christopher Will Oct 10 '12 at 9:59
Where is your code ? ... let see what we can do –  Baba Oct 10 '12 at 9:59
Some thing is missing in your question. I think it's about logic. –  Namal Oct 10 '12 at 10:02
I missed a part to the question, I have added this as I am unsure how I can implement this –  nsilva Oct 10 '12 at 11:12
add comment

2 Answers

up vote 1 down vote accepted

For the initial question, just make two queries as already suggested by fufu.

To get the highest value in FixedFareID plus 1, you can use MAX(FixedFareID)+1

share|improve this answer
add comment

first try inserting into the one database. IF the data is inserted try using the same query to insert into the second database.

share|improve this answer
add comment

Your Answer


