Welcome to WebmasterWorld Guest from 22.214.171.124
I have been trying to wrap my brains around this all evening but still can't work it out so asking for help.
I have 2 tables in a mysql database, guests and hotels. Guest table has "userid" row and "favouritehotel" row. Hotel has "hotelid" row.
The hotelid is already saved in a session as $hotelid.
I want the following to happen:
When i input the "userid" into a text box, i want it to compare the "favouritehotel" from the user table to the "hotelid". If they are the same, i want it to do a sum which would be:
"Transaction Cost" x 1.5
If the "favouritehotel and the "hotelid" do not match, i want the sum to do:
"Transaction Cost" x 1
Just to give you the context behind it incase this is confusing... it's a points system. If the user's favorite hotel is the same as the hotelid doing the sum then they get 1.5 x the transaction cost. If they are not the favourite hotel, they only get 1 x the transaction cost.
Any support greatly appreciated!
Something like this will work assuming you're using MySQL.
$query = "SELECT * FROM guests WHERE userid = '$userid' AND favouritehotel = '$hotelid'";
$result = mysql_query($query);
$total = $transaction_cost * 1.5;
$total = $transaction_cost;