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 8202289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:07:50+00:00 2026-06-07T07:07:50+00:00

I have a small project I have been working on. I had to create

  • 0

I have a small project I have been working on. I had to create a area conversion calculator using one file or PHP_SELF. The problem I am having is the form is working and outputs the number, but it will only ouput the last if statement no matter what conversion method I pick. It will always output Sq.Miles.

if (!empty($_POST['con'])) {
    $con = $_POST['con'];
} else {
    $error .= "You need to select a conversion Method. <br>";
}
if (!empty($_POST['number'])) {
    $num = $_POST['number'];
    } else {
    $error .= "You need to type in a number. <br>";
} 
if (empty($error)) {
    if ($con = "SFSM") {
        $result = $num * 0.093 . " Sq. Meters";
    }
    if ($con = "SYSM") {
        $result = $num * 0.84 . " Sq. Meters";
    }
    if ($con = "SMSK") {
        $result = $num * 2.6 . " Sq. Kiometers";
    }
    if ($con = "SMSF") {
        $result = $num * 10.76 . " Sq. Feet";
    }
    if ($con = "SMSY") {
        $result = $num * 1.2 . " Sq. Yards";
    }
    if ($con = "SKSM") {
        $result = $num * 0.38 . " Sq. Miles";
    }
}
}
?>
<form method="post" action="area2.php">
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Area Conversions</td>
</tr>
<tr>
<td>Conversion Method</td>
<td>Number</td>
</tr>
<tr>
<td>
<select name="con">
 <option selected="selected" style="color:#CCC"></option>
 <option value="SFSM">Square Feet to Square Meters</option>
 <option value="SYSM">Square Yards to Square Meters</option>
 <option value="SMSK">Square Miles to Square Kilometers</option>
 <option value="SMSF">Square Meters to Square Feet</option>
 <option value="SMSY">Square Meters to Square Yards</option>
 <option value="SKSM">Square Kilometers to Square Miles</option>
 </select>
 </td>
 <td>
  <input type="text" name="number" size="10" value = "<?php if ($num){ echo $num; } else           {           echo "Insert Number"; } ?>" onfocus="this.value==this.defaultValue?this.value='':null"/><br />
  </td>
  </tr>
  <tr>
  <td colspan="2">
       <input type="submit" value="Calculate" name="submit" />
       <input type="reset" value="reset" name="reset" />
</td>
</tr>
<?php
if (!empty($error)) {
echo $error;
}elseif (!empty($result)) {
echo "<tr><td colspan=\"2\">Result: " . $result . " </td></tr>";
}
?>
</table>
</form>
  • 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-06-07T07:07:51+00:00Added an answer on June 7, 2026 at 7:07 am

    Try:

    if ($con == "SFSM") {
    

    The = operator is assignment; == is comparison.

    Essentially, your if statements are all evaluating to true; and since they all set the variable, it’s only the last call that’s actually appearing

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

Sidebar

Related Questions

I have been working on a small file manager module in a project where
I have been working on a project that dynamically creates a javascript file using
I am working on a small project and i have got a problem. If
I have this small project I have been working on. I have a MySQL
I have a small c++ project I've been working on in XCode, that I'd
I have been working on a small project on recent delived ASP.NET MVC 3
I have been working with a small project recently which involves Struts 2 and
I have been working through a very small-scale WPF project in order to familiarize
I have been working with a small team on a small project about fiction
I have a small open source OSX project I've been working on that I'd

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.