its a simple piece of code but i seem to be having problems
this is the code below

  1. $comp_tot="76";
  2. if ($credits = $comp_tot)
  3. //$sub=$credits_3;
  4. $tot="76";
  5. $ans_1= $tot-$credits;
  6. echo"<p>$ans_1</p>";
  7. echo "there";

this code is working however i dont want the condition to be an equal sign
i want when credits is less that 76 for the code to give me back a number which is the difference between the 76 and the value which is stored in credits. like i said it works as it stands now but i want the condition to be a less than equality. can anyone enlightened me on how to do this please
thanks

um...... Use the less-than relational operator '<'. It doesn't take a geek to figure that one out... :P

i was doing that all the time and i was getting an error that y i asked so i can know where i am going wrong

Then it is advisable to post the revised code along with the error you receive. Without those, no one besides you has any clue. We're not mind-readers...

<?php

$input=56; // your input here, ex. 56
$credit=76;
if($input<$credit){
$dif = $credit-$input;
}

echo $dif;

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.