how to calculate % and how to stop form from auto submit.

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

how to calculate % and how to stop form from auto submit.

Post by adsegzy »

how to calculate % and how to stop form from auto submit.



Hello Success-Oriented People,

I want to calculated 90% and a particular amount am having in my database. I named the column of the amount in the database abalance. this is the code i tried but its not working,

Code: Select all

$ninetypercent=(90/100*'$abalance');
What is the way out?

Secondly, am having a form where members can edit their account. When the member clicked on edit profile from his/her welcome page, the below page will be opened. my problem is that starting the form with teh IF function in order to stop the form from submitting automatically, whenever the page is loaded, the page will not echo out the members informations but if i removed the IF function, all the members information will be display but the form will be submitting itself automatically.

Code: Select all

<?php
[color=#BF0000]if(!empty($_POST[Submit]))[/color]
{
include("customersinfodb.php");
$id=$_SESSION[id];
$check=mysql_query("select * from clients where id='$id'");
while($look=mysql_fetch_array($check))
{
      $id=$look[id];
      $ano=$look[ano];
      $fname=$look[fname];
      $mname=$look[mname];
      $lname=$look[lname];
      $address=$look[address];
      $address2=$look[address2];
      $city=$look[city];
      $state=$look[state];
      $country=$look[country];
      $pcode=$look[pcode];
      $gender=$look[gender];
      $pno=$look[pno];
      $pno2=$look[pno2];
      $atype=$look[atype];
      $currency=$look[currency];
      $status=$look[status];
      }
      $nfname=$_POST[fname];
      $nmname=$_POST[mname];
      $nlname=$_POST[lname];
      $naddress=$_POST[address];
      $naddress2=$_POST[address2];
      $ncity=$_POST[city];
      $nstate=$_POST[state];
      $ncountry=$_POST[country];
      $npcode=$_POST[pcode];
      $ngender=$_POST[gender];
      $npno=$_POST[pno];
      $npno2=$_POST[pno2];
      $natype=$_POST[atype];
      $ncurrency=$_POST[currency];
      $nstatus=$_POST[status];
      $update=mysql_query("update clients set fname='$nfname', mname='$nmname', lname='$nlname', address='$naddress', address2='$naddress2', city='$ncity', state='$nstate', country='$ncountry', pcode='$npcode', gender='$ngender', pno='$npno', pno2='$npno2', atype='$natype', currency='$ncurrency', status='$nstutas' where ano='$ano'");
      if(!$upload)
      echo "The Information is not updated, try again.<br>";
      else
      echo "The Information is updated successfully.<br>";
     }
      ?>
what can i do to this form?

Regards,
adsegzy
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: how to calculate % and how to stop form from auto submit.

Post by josh »

0.9 * $balance
90/100 = .9
'$balance' is simple escaping the value ( the single quote )
Post Reply