PHP Parameter Application

Hi am researching on doing an application that requires me to execute different commands based on the parameter given... the problem is that the parameters build upon the last..

To start lets take an example of booking a flight to from point A to D. Here is what would happen.

First Parameter: 5
That presents you with options to choose from:
Travelling from:
1.A
2.B
3.C
4.D

So you reply with

5*1 to show your travelling from 1

Next prompt is:

Travelling to:

1. A
2. B
3. C
4. D

You reply with 5*1*4 which shows you have chose

Next is When are you travelling...for this you type mmddyyyy
so your next parameter looks

5*1*4*26102009

And probably finally,

What is your last name? Which you reply
5*1*4*26102009*LASTNAME

Some specific details...when you first do the request... i.e parameter 5 alone...you get assigned a unique ID that stays with you till you finish (this part is already working).

So the help i need..... i would like to some general idea on how to;

1. Have the options of A to D come from the DB and ensure the table ID are always valid (that might not be so hard)

2. At the end (when i get thte name), i would like to break this entire parameter into variables in php

$from, $to, $datetravel,$name

This string varies but the * is always separating the different variables...is there any function to tell it make this an array based on * instead of the normal comma separator for arrays.

Any other help how to make this will help!

3.
bernsoft1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrianMMCommented:
explode() can take an argument of separator type...

$param_string = "5*1*4*26102009*LASTNAME" // probably thru $_RQUEST than set but i'll leave that to you...

$parameters = explode("*", $param_string);

echo "id: ".$parameters[0];
echo "to: ".$parameters[1];
echo "from: ".$parameters[2];
echo "date: ".$parameters[3];
echo "lastname: ".$parameters[4];

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Hmm.. Is this by any chance a homework assignment?

Note that in your example above, if the "from" point is "A", there is no use in having the "to" point include "A"

Dates in PHP should be interpreted via strtotime(), and then reinterpreted into DATETIME strings in ISO8601 format using date('c') or date('Y-m-d');

Instead of carrying the data fields around in an asterisk-delimited string, a technically competent design would put each field into a table of the data base at the time it was entered.  

It seems like you have a lot of questions here, and so you might benefit from a good beginning primer on the use of PHP and data bases.  This is one of the best, and it is available in PDF format so you can download a copy right away.

http://www.sitepoint.com/books/phpmysql1/

Best of luck with your project, ~Ray
0
bernsoft1Author Commented:
Thanks for your help Briand & Ray.

Its not homework.... Its actually a project for a mobile application service...USSD technology....you know  the ones you type *144*2# to query for information.....

0
Ray PaseurCommented:
Understood.  Then explode() is the way to take the string apart into component pieces.
0
bernsoft1Author Commented:
I eventually used explode and switch
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.