Coming from a non-programmer...
 
If you were to take the cars' IDs and put them in an array named for the
track a specific group of cars is on, that would give you indexes, thus
positions, from 0-N depending on how many cars are there. Any time you have
to add or delete cars, you should be able to delete or add the ID from or to
the array and the indexing would automatically tell you what position all of
the cars are in. You should be able to move cars (IDs) around in the array
with PHP too.
 
So you'd have:
 
$track1 = array(2,4,6,8); //where 2,4,6,8 are the IDs of rail cars
 
And you'd use the serialize and unserialize functions to get the data into
and out of MySQL and PHP to manipulate the order of the IDs inside the
array.
 
Like I said, I'm a non-programmer, but a track with cars on it sounds pretty
similar to a real-world representation of an array structure to me. I'm sure
there will be myriad other ways to get at this problem with their own good
and bad points.
 
I agree with John though, sounds like a fun project.
 
Rich

-----Original Message-----
From: Adam Voigt [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 11:25 AM
To: Rankin, Randy
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Help with MySQL Logic


Heh. Sounds like a programming class homework project. 
I would say through the clever use of where clauses's, like: 

UPDATE position SET posistion = (position-1) WHERE position > $idremoved; 

Would work, assuming $idremoved containted the position of the car removed. 

On Mon, 2003-03-03 at 10:59, Rankin, Randy wrote: 

Hello All, 

This may be a bit off topic. If so, my apololgies. 

A client of mine, a rail car storage company, has asked that I create a 
PHP/MySQL application in which they will maintain and track rail cars. I am 
having a bit of trouble however working through one of thier requirements. 
They need to know in what position the rail car is on each track. For 
example, they might have a track called X which will hold 30 rail cars. They

would enter the car information for 30 cars and associate each of them with 
track X. If one of the car owners decides to move car 3 out of storage, then

the remaining 29 cars must be re-numbered ( ie; car 1 and 2 would remain and

car 4-30 would become car 3-29 ). In the same manner, I need to be able to 
add a car to the track once an empty slot is available. For example, If the 
new car goes at the front of the track then it would become car 1 and the 
remaining cars, originally numbered 1-29 would become 2-30. 

I hope I explained thourougly. Any suggestions would be appreciated. 

Randy 


-- 

Adam Voigt ([EMAIL PROTECTED])

The Cryptocomm Group

My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc

Reply via email to