Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    New Lounger
    Join Date
    Oct 2010
    Location
    Cambridge, UK
    Posts
    6
    Thanks
    0
    Thanked 2 Times in 2 Posts
    PHP Code:
    <?php
        error_reporting
    (E_ALL);
        
    ini_set('display_errors''1'); 
        
    date_default_timezone_set('europe/london');
        
    $hostname "localhost";
        
    $database "12string";
        
    $username "root";
        
    $password "root";
        try{
            
    $dbconn = new PDO("mysql:host=$hostname;dbname=$database"$username$password);
            
    $dbconn->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
            
    $dbconn->exec('SET NAMES "utf8"');
        }catch (
    PDOException $e){
            
    $error "Unable to connect to the database server.";
        }
        if(!empty(
    $_POST["submit"])){
            try{
                
    $query $dbconn->prepare("
                    SELECT 
                        * 
                    FROM 
                        `payments` 
                    WHERE 
                        `apt` = :apt
                "
    );
                
    $query->execute(array(
                    
    ":apt" => $_POST['acctno']
                ));
                
    $lines = array();
                if(
    $query->rowCount() > 0){
                    while(
    $row $query->fetch()){
                        
    $lines = array(
                            
    "acctno" => $row["acctno"],
                            
    "bname" => $row["bname"],
                            
    "purpose" => $row["purpose"],
                            
    "paidamt" => $row["paidamt"],
                            
    "amtdue" => $row["amtdue"],
                            
    "prevbal" => $row["prevbal"],
                            
    "datepaid" => $row["datepaid"],
                            
    "pd" => $row["pd"]
                        );
                    }
                }else{
                    
    $error "No listing for apartment!";    
                }
            }catch(
    PDOException $e){
                
    $error "Error retrieving payments: ".$e->getMessage();
            }
        }else{
            if(!empty(
    $_POST["update"])){
                try{
                    
    $query $dbconn->prepare("
                        UPDATE
                            `payments` 
                        SET
                            `name` = :name,
                            `amtpaid` = :amtpaid,
                            `rentdue` = :rentdue,
                            `prevbal` = :prevbal,
                            `hudpay` = :hudpay,
                            `tentpay` = :tentpay,
                            `datepaid` = :datepaid,
                            `late` = :late,
                            `comments` = :comments,
                            `paidsum` = :paidsum
                        WHERE 
                            `apt` = :apt
                    "
    );
                    
    $query->execute(array(
                        
    ":name" => $_POST["name"],
                        
    ":amtpaid" => $_POST["amtpaid"],
                        
    ":rentdue" => $_POST["rentdue"],
                        
    ":prevbal" => $_POST["prevbal"],
                        
    ":hudpay" => $_POST["hudpay"],
                        
    ":tentpay" => $_POST["tentpay"],
                        
    ":datepaid" => $_POST["datepaid"],
                        
    ":late" => $_POST["late"],
                        
    ":comments" => $_POST["comments"],
                        
    ":paidsum" => $_POST["paidsum"],
                        
    ":apt" => $_POST['apt']
                    ));
                }catch(
    PDOException $e){
                    
    $error "Error updating payments: ".$e->getMessage();
                }
            }
        }
        include 
    "dom.html.php";

    HTML Code:
    <!DOCTYPE html>
    <html>
        <head>
            <title>12 String</title>
            <meta charset="utf-8" />
            <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
            <link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"/>
        </head>
        <body>
            <nav class="navbar navbar-default" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="http://drmsite.co.uk">12String</a>
                    </div>
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse">
                        <ul class="nav navbar-nav" id="siteLinks">
                            <li class="active">
                                <a href="#">Record Payment</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
            <div class="container">
                <form class="form-horizontal" role="form" method="post" action="#">
    <?php if(isset($lines)): ?>
                    <div class="form-group">
                        <label for="acctno" class="col-sm-2 control-label">Account Number</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="acctno" disabled value="<?=$lines["acctno"]?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="bname" class="col-sm-2 control-label">Name</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="bname" disabled value="<?=$lines["bname"]?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="purpose" class="col-sm-2 control-label">Description</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="purpose" disabled value="<?=$lines["purpose"]?>">
                        </div>
                    </div>
                    <div class="well">
                        <div class="form-group">
                            <label for="pay" class="col-sm-2 control-label">Pay</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="pay">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="amtdue" class="col-sm-2 control-label">Due</label>
                            <div class="col-sm-10">
                                <input type="number" data-original="<?=$lines["amtdue"]?>" class="form-control" name="amtdue" value="<?=$lines["amtdue"]?>" disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="paidamt" class="col-sm-2 control-label">Paid</label>
                            <div class="col-sm-10">
                                <input type="number" data-original="<?=$lines["paidamt"]?>" class="form-control" name="paidamt" value="<?=$lines["paidamt"]?>" disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="datepaid" class="col-sm-2 control-label">Date</label>
                            <div class="col-sm-10">
                                <input type="date" class="form-control" name="datepaid">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pd" class="col-sm-2 control-label">PD</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="pd" value="<?=$lines["pd"]?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="check" class="col-sm-2 control-label">Check</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="check">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default" name="update" value="check">Update account</button>
                            </div>
                        </div>
                    </div>
    <?php else: ?>                 
                    <div class="form-group">
                        <label for="acctno" class="col-sm-2 control-label">Account Number</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="acctno" placeholder="Enter account number here">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-default" name="submit" value="check">Select account</button>
                        </div>
                    </div>
    <?php endif; ?>                
                </form>
            </div>
            <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
            <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.js"></script>
            <script>
                $(function(){
                    $("input[name='pay']").on("change", function(){
                        var $this = $(this);
                        var $due = $("input[name='amtdue']");
                        var $payed = $("input[name='paidamt']");
                        var pay = parseInt($this.val(), 10);
                        var due = parseInt($due.data("original"), 10);
                        var payed = parseInt($payed.data("original"), 10);
                        $due.val(due - pay);
                        $payed.val(payed + pay);
                    });
                });
            </script>
        </body>
    </html>
    My bad - spun up a server and had a play with the following SQL:

    Code:
    CREATE TABLE IF NOT EXISTS `payments` (
      `acctno` int(11) NOT NULL,
      `bname` varchar(255) NOT NULL,
      `purpose` varchar(255) NOT NULL,
      `paidamt` float NOT NULL,
      `amtdue` float NOT NULL,
      `prevbal` float NOT NULL,
      `datepaid` datetime NOT NULL,
      `pd` int(11) NOT NULL,
      `apt` int(11) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    --
    -- Dumping data for table `payments`
    --
    
    INSERT INTO `payments` (`acctno`, `bname`, `purpose`, `paidamt`, `amtdue`, `prevbal`, `datepaid`, `pd`, `apt`) VALUES
    (1, 'Something here', 'Fix the sink', 10, 100, 110, '2014-07-30 11:28:26', 12, 1);
    Will work on dom.html.php in order to show the data returned from the query now.
    Last edited by annoyingmouse; 2014-07-30 at 09:32. Reason: Altered code to show data. Try that and see how you go.

  2. #17
    New Lounger
    Join Date
    Jul 2014
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts
    you mentioned silly, I beg to differ LOL, I spend my time writing docs, such as one to show what city a phone call comes, one I use when I'm performing. I use my laptop instead of sheet music, click on the name and the lyrics & chords are there to see. I have a system for access to
    my email accounts, to modify, list, a dropdown menu that shows the selected file and updates the records date of last used. The menu displays the options in alternate colors.
    Here is the code where all starts It has a fish eye effect, radio buttons
    linking several email providers, browsers & email options: try it out!

    <html><head>
    <style type="text/css">
    span {font-size: x-large}
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function convertPreBlocks() {}
    var regular = "medium";
    function bigger(thing){
    thing.style.fontSize = "x-large";
    siblingElement = thing.previousSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = "large
    break;
    }
    siblingElement = siblingElement.previousSibling;
    }
    siblingElement = thing.nextSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = "xx-large";
    break;
    }
    siblingElement = siblingElement.nextSibling;
    }
    }
    function normal(thing){
    thing.style.fontSize = x-large;
    siblingElement = thing.previousSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = large;
    break;
    }
    siblingElement = siblingElement.previousSibling;
    }
    siblingElement = thing.nextSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = large;
    break;
    }
    siblingElement = siblingElement.nextSibling;
    }
    }
    // End -->
    </script>
    <style type="text/css">
    span {font-size: }
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- tHIS IS THe top frame in emailget.html -->
    <!-- Begin
    function convertPreBlocks() {}
    var regular = "medium";
    function bigger(thing){
    thing.style.fontSize = "xx-large";
    siblingElement = thing.previousSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = "large";
    break;
    }
    siblingElement = siblingElement.previousSibling;
    }
    siblingElement = thing.nextSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = "large";
    break;
    }
    siblingElement = siblingElement.nextSibling;
    }
    }
    function normal(thing){
    thing.style.fontSize = x-large;
    siblingElement = thing.previousSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = large;
    break;
    }
    siblingElement = siblingElement.previousSibling;
    }
    siblingElement = thing.nextSibling;
    while(siblingElement) {
    if(siblingElement.tagName=="SPAN") {
    siblingElement.style.fontSize = large;
    break;
    }
    siblingElement = siblingElement.nextSibling;
    }
    }
    // End -->
    </script>
    <script language="Javascript" type="text/javascript">
    function gotolink() {
    var destination= self.location;

    for(var i = 0; i<document.formname.radiobutton.length; i++){
    if(document.formname.radiobutton[i].checked) {
    destination=document.formname.radiobutton[i].value }
    }
    window.location = destination;
    }
    </script>
    </head>
    <body bgcolor="#ccffff"><b>
    <p><p><p><p><p><p><p><p>
    <table border="0" width=1000>
    <tr><td bgcolor="#ccffff"><b><div align=center>
    <td align=center bgcolor="#ccffff">
    <FONT style="FONT-WEIGHT: bold; FONT-SIZE: 26pt; FONT-STYLE: italic">
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    Email Portal</span><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    just having a little</span><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    fun while at the same I'm </span><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    creating a useful shortcut for</span><br>
    <form name="formname">
    <input name="radiobutton" type="radio" value="http://yahoo.com"
    onClick="gotolink()"><font color="red"> Yahoo</FONT>
    <input name="radiobutton" type="radio" value="http://www.bing.com"
    onClick="gotolink()"> <font color="red">Bing</FONT>
    <input name="radiobutton" type="radio" value="http://outlook.com"
    onClick="gotolink()"> <font color="blue">Msn</FONT>
    <input name="radiobutton" type="radio" value="http://gmail.com"
    onClick="gotolink()"> <font color="red">Gmail</FONT>
    <input name="radiobutton" type="radio" value="http://firefox.com"
    onClick="gotolink()"> <font color="red">Firefox</FONT><br>
    <input name="radiobutton" type="radio" value="http://localhost/home/emailopts.html"
    onClick="gotolink()"> <font color="blue"> Email Options</FONT><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    users to link to often </span><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    used emails. This is another</span><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    in a never ending wave of </span><br>
    <span onmouseover="bigger(this)" onmouseout="normal(this)">
    mlnd boggling intellect</span><br>
    </tr></td></table></FONT></br></div></td></body></html>





    for

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •