
10-19-2006, 06:52 PM
|
|
Newbie
|
|
Join Date: Sep 2006
Posts: 7
|
|
calculator
Hey, Im building a website for my work. And they own a Travel Company. I want to do a PHP or HTML thing where they can click how many people are traveling and where to and it comes up with a answer As In How much it will cost. If anyone can code one or knows where i can get one would really help
23 People
To London
From Leeds
= £230
See what i mean? I want it so when they click or type the opions they want it will have a calculat button at the bottem and tell them the price
Cheers Ricky
|

10-19-2006, 07:01 PM
|
|
Web Hosting Guru
|
|
Join Date: Feb 2006
Location: Pittsburgh PA
Posts: 289
|
|
i would start looking into javascript, I want to do the same thing, but i cant really find any good information on it. however, I have seen what your talking about done in java, but i dont have to code =/
|

10-19-2006, 07:07 PM
|
|
Newbie
|
|
Join Date: Sep 2006
Posts: 7
|
|
Yeah, Java And php arnt really my thing i only know HTML and how to edit PHP.. lol So im a bit noobbish on that
|

10-19-2006, 08:00 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Oct 2006
Posts: 44
|
|
Whether you want to use a client-side language like javascript, or a server side technology like php or ruby will depend on your needs. If your prices are fixed then javascript can offer a faster user experience, but isn't as flexible as the server technologies. PHP and the other server side technologies will allow you to store prices in a database and update them in a single place, which makes ongoing administration easier. The price you pay is you need more resources to run server side technologies. AJAX would give you a good compromise between the two options, but will cost more to set up.
There are a number of places you can go to find scripts on the web. Just do a Google search for 'php scripts' or the like and you'll find plenty of sites that have scripts. I haven't used any of these sites, so I can't offer any recomendations. But I will warn you not to use any pre made script if you can't understand the php well enough to be sure there aren't any security holes.
I can't really say what it would cost you to have it done either. The old maxim about 'you get what you pay for' applies. You don't want to over pay, but you don't want shoddy, buggy scripts either.
__________________
Andrew
Spry VPS Hosting cPanel VPS, Plesk VPS, Webmin VPS, Shared, Domain Registration, Dedicated and Colo
VPSLink Cheap VPS accounts CentOS, Fedora 4/5/6, RHEL, Gentoo, Debian, Ubuntu -- Dapper/Edgy, Slackware, OpenSUSE, LAMP + Ruby pre-installed available
|

10-19-2006, 08:02 PM
|
|
Newbie
|
|
Join Date: Sep 2006
Posts: 7
|
|
cheers andrew Ill keep that in mind
|

10-20-2006, 12:12 AM
|
|
Junior Guru
|
|
Join Date: Jan 2003
Location: USA, FL
Posts: 241
|
|
Rick if you know the prices of the ticket then here is a simple script.
This script is just and example and is not for production use.
This is the longer, hardcoded away of doing it but it could be done by database which would be easier to maintain and change prices like spryandrew explained.
Thank you and have a good day
Code:
<?php
$get_to = $_POST['to'];
$get_from = $_POST['from'];
$get_ppl = $_POST['ppl'];
if(isset($get_to) && isset($get_from) && isset($get_ppl)){
if($get_to == 'london' && $get_from='leads'){
$price = $get_ppl * 200;
echo 'Cost is: '.$price.'<br />';
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
To:<select name="to">
<option value="london">London</option>
</select>
From: <select name="from">
<option value="leads">Leads</option>
</select>
People: <input type="text" name="ppl" />
<input type="submit" value="Submit" />
</form>
|

10-20-2006, 07:52 AM
|
|
Temporarily Suspended
|
|
Join Date: Jan 2005
Posts: 106
|
|
Quote:
|
Originally Posted by Syphic
Rick if you know the prices of the ticket then here is a simple script.
This script is just and example and is not for production use.
This is the longer, hardcoded away of doing it but it could be done by database which would be easier to maintain and change prices like spryandrew explained.
Thank you and have a good day
Code:
<?php
$get_to = $_POST['to'];
$get_from = $_POST['from'];
$get_ppl = $_POST['ppl'];
if(isset($get_to) && isset($get_from) && isset($get_ppl)){
if($get_to == 'london' && $get_from='leads'){
$price = $get_ppl * 200;
echo 'Cost is: '.$price.'<br />';
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
To:<select name="to">
<option value="london">London</option>
</select>
From: <select name="from">
<option value="leads">Leads</option>
</select>
People: <input type="text" name="ppl" />
<input type="submit" value="Submit" />
</form>
|
That works but takes allot of editing if you are going to use more destinations.
|

10-20-2006, 10:52 AM
|
|
Newbie
|
|
Join Date: Sep 2006
Posts: 7
|
|
To be honest i cant be botherd messing about withdata base's id rather have it in a script and edited the scripts
|

10-20-2006, 01:53 PM
|
|
Web Hosting Evangelist
|
|
Join Date: Oct 2004
Location: UK
Posts: 487
|
|
If your going to avoid using a database, your going to be best off using Arrays to store the locations, rather than using hundreds/thousands of boolean statements.
Look into using dual arrays to store the 2 locations and the price for the 2.
The other option is flat file databasing, avoiding using MySQL.
|

10-20-2006, 02:20 PM
|
|
Predatory Poster
|
|
Join Date: Jul 2003
Location: Goleta, CA
Posts: 5,550
|
|
I strongly urge you to go the database route. What happens when the travel agency wants you to sort trips by popularity. Maybe they want added information like which trips have a lot of viewers but no buyers. This seems like it would be much easier to expand using a database system. maybe the price is too high etc. Find ways to make more money whenever you can.
__________________
Patron: I'd like my free lunch please.
Cafe Manager: Free lunch? Did you read the fine print stating it was an April Fool's joke.
Patron: I read the same way I listen, I ignore the parts I don't agree with. I'm suing you for false advertising.
Cafe Owner: Is our lawyer still working pro bono?
|

10-20-2006, 06:58 PM
|
|
Junior Guru
|
|
Join Date: Jan 2003
Location: USA, FL
Posts: 241
|
|
As I stated within my code; the easier and better way would be to do by database. The small 5 min work was a concept to give a raw/basic idea of what you were askin for and what you were wanting. Again, as I stated, it was the hardcoded way and if you know the basics this could be easily integrated into the use of a database as below. Again, this is not for production but for a basic example.
Example and this is only the PHP part.
[code]
Code:
$get_to = $_POST['to'];
$get_from = $_POST['from'];
$get_ppl = $_POST['ppl'];
// table structure - flight table : Fields (flight_id, flight_to, flight_from, flight_price)
$result = mysql_query("SELECT * FROM flight_table WHERE flight_to='$get_to' && '$get_from' ");
$flight = mysql_fetch_assoc($result);
if(isset($get_to) && isset($get_from) && isset($get_ppl)){
if($get_to == 'london' && $get_from='leads'){
$price = $get_ppl * $flight['flight_price'];
echo 'Cost is: '.$price.'<br />';
}
}
This code atleast needs some some sql injection and validation of variables. I would also suggest a more optmized approach for the database. Something like:
table: location_to
location_to_id
location_to_name
table: location_from
location_from_id
location_from_name
table: flight_price
flight_id
flight_to
flight_from
flight_price
Again this is just one of the many ways of doing it. It hightly depends on how complex and detailed it needs to be.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|