Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:14:40+00:00 2026-05-25T01:14:40+00:00

Hello I can’t get my script fully operational. I have it calculating properly but

  • 0

Hello I can’t get my script fully operational.

I have it calculating properly but now need a query for fuel type.

<?php

include 'mysql_connect.php';

$query = "SELECT * FROM fuel_price WHERE FuelType='Oil'" ;

$result = mysql_query($query);
$price= mysql_fetch_array($result);


if(isset($_POST['submit'])){

 echo "The Price Today is  ";

 echo "£"; echo $_POST['qtylitres'] * $price ['Price'];



 } else {

echo "Please select value";

}

?>

I need to to check fueltype selected on form and calculate total accordingly.

eg $query = “SELECT * FROM fuel_price WHERE FuelType='{$_POST[‘fueltype’];}'” ;

Please help anyone under pressure.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:14:41+00:00Added an answer on May 25, 2026 at 1:14 am
    include 'mysql_connect.php';
    
    if(isset($_POST['submit'])){
        if($_POST['inputEmail'] == ''){
            echo 'Please enter an email address';
        } else{
            // show price
            $fuelPriceQuery = sprintf("SELECT `Price` FROM fuel_price WHERE FuelType = '%s' LIMIT 1",
                        mysql_real_escape_string($_POST['fueltype']));
    
            $fuelPriceResult = mysql_query($fuelPriceQuery);
            $price           = mysql_fetch_array($fuelPriceResult, MYSQLI_ASSOC);
            echo 'The Price Today is £'.($_POST['qtylitres'] * $price['Price']);
    
            // insert email
            $addEmailQuery  = sprintf("INSERT INTO `subscribe`(`Email`) VALUES('%s')",
                                mysql_real_escape_string($_POST['inputEmail']));
            $addEmailResult = mysql_query($addEmailQuery);
            if($addEmailResult){
                echo 'You have successfully subscribed';
            } else{
                echo 'Sorry, we could not subscribe you at this time. Please try again.';
            }
        }
    } else {
        echo "Please select value";
    }
    

    A couple of things to note:

    1. Always make sure to escape the user input by using mysql_real_escape_string, if you are not using prepared statements such as PDO, MySQLi, etc…

    2. I added the LIMIT clause to the query so mysql_fetch_array will work, because if it returns more than one row, then you would have to handle it in a loop.

    3. It is not necessary to use multiple echos, in fact it is better if you use as few as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I need to have multiple language support of my django admin application.I can
Using a default index, one can do nodeIndex.get(message, Hello) for exact matches, or nodeIndex.query(message,
HEllo , i can not find any way to get horizontal or/and vertical resolution
I need to know how i can make a string like hello to Hello
Hello can anybody see why this query fails? SELECT A.idAd, A.ads_in_Cat, A.title, A.currency, A.price,
Hello how can I have like a catalog for a property in .net VB
I have strings that need converting like so, 'hello world' = 'helloWorld' And also
actually i was opened question previously, but can't get answer what i exactly want,
Why the #hello can fade out but not show anymore?? thanks! <!DOCTYPE html> <html>
Hello how can I delete anything of this string and have only the XBH1dcHoL6Y

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.