Dear all, I would really appreciate your help and assistance with a bug i'm facing in myphpadmin Mysql table.

I have a table which is named as total amount. I also have a front end php. interface where i do my data entry from. When I enter for example (100000) it displays as its is, but I'm facing difficulty when i have to check my totals because i want when ever i eneter (100000) it should automatically display or store my data as (100,000) or if im entering an amount ( 54600) fifty four thousand six hundred it should diplay it ( 54,600) so the confusion doesn't occur in reading the amounts. I'm going to paste the coding of my php page and if you think there is anything i need to make changes from dreamweaver i will do that accordingly. thank you ! i really appreciate the effort. Thanks!

<script language="javascript" src="calendar/calendar.js"></script>

<script type="text/javascript">
function vali()
{

var x=document.forms["form11"]["photo"].value;
if (x==null || x=="")
  {
  alert("Please Select BPV PDF");
  return false;
  }


}
</script>


<script type="text/javascript">
function summall()
{


var a = eval(document.form11.amount0.value);
var b = eval(document.form11.amount1.value);
var c = eval(document.form11.amount2.value);
var d = eval(document.form11.amount3.value);
var e = eval(document.form11.amount4.value);
f = a + b;
g = f + c;
h = g + d;
i = h + e;

document.form11.tammount.value = i;

}
</script>

<link href="default.css" rel="stylesheet" type="text/css" />
        <h2>Add BPV. 
</h2>
<div class="box">
  <form name="form11" method="post" action="bpvadded.php" enctype="multipart/form-data" onsubmit="return vali()" >
  <table width="100%" border="1" bordercolor="#99CC00">
    <tr>
      <td><table width="100%" border="0">
        <tr>
          <td colspan="2"><h3>Link Document Path: </h3></td>
          <td colspan="6">&nbsp;</td>
          </tr>
        <tr>
          <td colspan="8"><input type="hidden" name="size" value="3500000" />
              <input type="file" name="photo" /></td>
        </tr>
        <tr>
          <td colspan="8"><table width="100%" border="0">
            <tr>
              <td width="12%">BPV #</td>
              <td width="13%"><input name="bpv" type="text" id="bpv" size="8"/></td>
              <td width="12%">Bank Name </td>
              <td width="11%"><select name="bname" id="bname" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
                <option selected="selected" value="section/0">- Select -</option>
                <?php 
            include("includes/DB.php"); 
    $tbl_name="bank"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['bname'] .'">'.$row['bname'] .'</option>';

    mysql_close($con);
?>
              </select></td>
              <td width="15%">Account No </td>
              <td width="37%" colspan="3"><input name="acno" type="text" id="acno" size="8" /></td>
              </tr>
            <tr>
              <td>Cheque No</td>
              <td><input name="chq" type="text" id="chq" size="8" /></td>
              <td>Paid to </td>
              <td><input name="paidto" type="text" id="paidto" size="8" /></td>
              <td>Date:</td>
              <td colspan="3"><label>
                <?php

                    require_once('calendar/classes/tc_calendar.php');
                      $myCalendar = new tc_calendar("dateff", true, false);
                      $myCalendar->setIcon("calendar/images/iconCalendar.gif");
                      //$myCalendar->setDate(date('d'), date('m'), date('Y'));
                      $myCalendar->setPath("calendar/");
                      $myCalendar->setYearInterval(2000, 2015);
                      $myCalendar->dateAllow('2000-01-01', '2015-01-01');
                      $myCalendar->setDateFormat('j F Y');
                      //$myCalendar->setHeight(350);
                      //$myCalendar->autoSubmit(true, "form1");
                      $myCalendar->setAlignment('left', 'bottom');
                      //$myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year');
                      //$myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month');
                      //$myCalendar->setSpecificDate(array("2011-06-01"), 0, '');
                      $myCalendar->writeScript();
                      ?>
              </label></td>
              </tr>
            </table></td>
          </tr>
        <tr>
          <td width="12%">&nbsp;</td>
          <td width="13%">&nbsp;</td>
          <td width="12%">&nbsp;</td>
          <td width="11%">&nbsp;</td>
          <td width="8%">&nbsp;</td>
          <td colspan="3">&nbsp;</td>
          </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td colspan="3">&nbsp;</td>
          </tr>
        <tr>
          <td>Project Code </td>
          <td><select name="prjcode0" id="prjcode0" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="projects"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['code'] .'">'.$row['code'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Budget Code</td>
          <td><select name="budjetcode0" id="budjetcode0" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="bcodes"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['account'] .'">'.$row['account'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Desc</td>
          <td width="17%"><input name="desc0" type="text" id="desc0" size="8" /></td>
          <td width="14%">Amount </td>
          <td width="13%"><input name="amount0" type="text" id="amount0" value="0" size="8" /></td>
        </tr>
        <tr>
          <td>Project Code </td>
          <td><select name="prjcode1" id="prjcode1" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="projects"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['code'] .'">'.$row['code'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Budget Code</td>
          <td><select name="budjetcode1" id="budjetcode1" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="bcodes"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['account'] .'">'.$row['account'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Desc</td>
          <td><input name="desc1" type="text" id="desc1" size="8" /></td>
          <td>Amount </td>
          <td><input name="amount1" type="text" id="amount1" value="0" size="8" /></td>
        </tr>
        <tr>
          <td>Project Code </td>
          <td><select name="prjcode2" id="prjcode2" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="projects"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['code'] .'">'.$row['code'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Budget Code</td>
          <td><select name="budjetcode2" id="budjetcode2" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="bcodes"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['account'] .'">'.$row['account'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Desc</td>
          <td><input name="desc2" type="text" id="desc2" size="8" /></td>
          <td>Amount </td>
          <td><input name="amount2" type="text" id="amount2" value="0" size="8" /></td>
        </tr>
        <tr>
          <td>Project Code </td>
          <td><select name="prjcode3" id="prjcode3" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="projects"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['code'] .'">'.$row['code'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Budget Code</td>
          <td><select name="budjetcode3" id="budjetcode3" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="bcodes"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['account'] .'">'.$row['account'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Desc</td>
          <td><input name="desc3" type="text" id="desc3" size="8" /></td>
          <td>Amount </td>
          <td><input name="amount3" type="text" id="amount3" value="0" size="8" /></td>
        </tr>
        <tr>
          <td>Project Code </td>
          <td><select name="prjcode4" id="prjcode4" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="projects"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['code'] .'">'.$row['code'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Budget Code</td>
          <td><select name="budjetcode4" id="budjetcode4" onchange="return (MM_jumpMenuadm('parent',this,0,this.selectedIndex))">
            <option selected="selected" value="section/0">- Select -</option>
            <?php 
            include("includes/DB.php"); 
    $tbl_name="bcodes"; // Table name
    $con = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * from $tbl_name";
    $result=mysql_query($sql) or die(mysql_error());

    while($row = mysql_fetch_array($result))
        echo '<option value="'.$row['account'] .'">'.$row['account'] .'</option>';

    mysql_close($con);
?>
          </select></td>
          <td>Desc</td>
          <td><input name="desc4" type="text" id="desc4" size="8" /></td>
          <td>Amount </td>
          <td><input name="amount4" type="text" id="amount4" value="0" size="8" /></td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
          <td colspan="6">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>Total Amount</td>
          <td><input name="tammount" type="text" id="tammount" size="8"  onfocus='summall()';/></td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
          <td colspan="6">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
          <td colspan="6">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><input type="submit" name="upload" title="Add data to the Database" value=" Add " class="login-btn"/></td>
        </tr>
      </table></td>
    </tr>
  </table>
</form>

</div>

Dear all, I would really appreciate your help and assistance with a bug i'm facing in myphpadmin Mysql table.

I have a table which is named as total amount. I also have a front end php. interface where i do my data entry from. When I enter for example (100000) it displays as its is, but I'm facing difficulty when i have to check my totals because i want when ever i eneter (100000) it should automatically display or store my data as (100,000) or if im entering an amount ( 54600) fifty four thousand six hundred it should diplay it ( 54,600) so the confusion doesn't occur in reading the amounts. I'm going to paste the coding of my php page and if you think there is anything i need to make changes from dreamweaver i will do that accordingly. thank you ! i really appreciate the effort. Thanks!

So you're asking how to format numbers (100000 to 100,000) with MySQL? If that's the case then this isn't an issue for your database. Number formatting should be handled at the application level. MySQL doesn't, and shouldn't, care how data is going to be interpreted or displayed. It's merely concerned with accurate and safe storage and retrieval of said data.

Given you're using PHP you can easily format your output via its number_format () function. Use that upon output of the number.

Also, there are far too many issues in your code for me to bother going over every single one. But you should know that it's horrifically inefficient to open a new connection to MySQL with each block of PHP.

hey bob thank you for taking out your time and replying to my post. I'm very new to php and mysql database. i would like to know where in myphpadmin i will use number_format() in my php file or in the database at the total amount table?

You don't use myphpadmin (I think you actually mean phpmyadmin), you write a line of php and tell it to display the number it reads from the database in the format you want. The number will be stored in the database in the database's format, and that has nothing to do with the display format, that's the phph script's job.

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.