Account with data and mysql data

0

Good afternoon, it's the following in my project I need to make an account so in the end to have the result for the client to know how much to pay, but I'm not able to do this account. In my case, I ask the days and then the room will have a price (which in this case is already registered in mysql) and I want to go get that data to mysql and make the account for example (amount = price * days) / p>

<html>

Uploaded data        

                                                 

<div id="middle">
   <br><br><p>Obrigado pela sua preferência!</p>
           <p>A partir deste momento, tem 24 horas para efetuar o pagamento e completar a sua estadia.</p>


                                Entity:             00000           

      <tr>
        <td>Referência:</td>
        <td>000 000 000</td>
      </tr>

      <tr>
        <td>Montante:</td>
        <td><?php $montante; ?>€</td>
      </tr>
    </table>



$ sql="select price from home where num_casa = 1"; $ result = mysqli_query ($ con, $ sql); $ row = mysqli_fetch_array ($ result);

// Form Variables $ name = $ _ POST ['name']; $ surname = $ _ POST ['surname']; $ email = $ _ POST ['email']; $ phone = $ _ POST ['phone']; $ contributor = $ _ POST ['contributor']; $ cc = $ _ POST ['cc']; $ address = $ _ POST ['address']; $ data_input = $ _ POST ['data_input']; $ data_out = $ _ POST ['data_out'];

$ price = $ row ["price"];

$ difference = strtotime ($ data_output) - strtotime ($ data_input); $ num_days = floor ($ difference / (60 * 60 * 24));

$ amount = ($ num_days * $ price);

echo " Name: ". $ name. ""; echo " Last name: ". $ last name. ""; echo " E-mail: ". $ email. ""; echo " Phone: ". $ phone. ""; echo " Taxpayer: ". $ taxpayer. ""; echo " Citizen Card: ". $ cc. "
"; echo " Address: ". $ address. ""; echo " Data entry: ". $ data_input. ""; echo " Date output: ". $ output_data. ""; echo " Number of days: ". $ num_days. "
";

// It will record the data entered by the user $ sql="INSERT INTO host (name, surname, email, telephone, taxpayer, cc, address, entry_date, exit_data, num_days) VALUES ('$ name', '$ lastname', '$ email', '$ phone', '$ contributor', '$ cc', '$ address',' $ entry_data ',' $ exit_data ',' $ num_days ') "; $ result = mysqli_query ($ con, $ sql); if ($ result) echo ""; else echo "An error occurred while trying to register data in the database!"; ? > Home Back

Someone can edit, I do not know how to format.

    
asked by anonymous 06.06.2018 / 19:44

1 answer

1

Hello,
If $row["preco"] is returning the correct value, try to change the assignment order of:
$row["preco"] = $preco;
for:% $preco = $row["preco"];
If $row["preco"] is not returning, something is wrong with sql.

    
06.06.2018 / 21:41