• WSannoyingmouse

    WSannoyingmouse

    @wsannoyingmouse

    Viewing 16 replies (of 16 total)
    Author
    Replies
    • in reply to: Is this JavaScript problem? #1460516

      Hi there,

      I’ve had a look and I’m a wee bit confused as there’s something of a mixture of languages at play. Looks like you’ve got PHP generating HTML and then interacting with JavaScript in order to do stuff? Is that the case?

      It might be worth looking at creating an index.php page where your logic is created and then an order.html.php (included in your index.php like this: include “order.html.php”;) where your data is displayed. You can have your index form accept post and update your database if it detects the if(isset($_POST[“submit”])){} // process form and then display error/success messages using the same order.html.php.

      I’m more than happy to help but I’d perhaps need to see the page in action first. Might I also suggest that you use the lovely jQuery JavaScript library as it makes accessing things in the DOM a breeze?

      Another suggestion is to use the PHP PDO class – makes your SQL ever so nice to look at:

      Code:
      setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              $dbconn->exec(‘SET NAMES “utf8″‘);
          }catch (PDOException $e){
              $error = “Unable to connect to the database server.”;
              // Display error to user
              exit();
          }
          /* SPECIFIC */
          try{
              $query = $dbconn->prepare(”
                  UPDATE 
                      oocust 
                  SET  
                      amtdue = :amtdue,
                      paidamt = :paidamt, 
                      datepaid = :datepaid, 
                      pd = :pd
                  WHERE 
                      acctno = :acctno
              “);
              $query->execute(array(
                  “:amtdue” => $_POST[‘amtdue’],
                  “:paidamt” => $_POST[“paidamt”],
                  “:datepaid” => $_POST[“datepaid”],
                  “:pd” => $_POST[“pd”], 
                  “:acctno” => $_POST[“acctno”]
              ));        
          }catch(PDOException $e){
              $error = “Error retrieving user: “.$e->getMessage();
              // Display error to user
              exit();
          }

      JavaScript is a top language! But can be misused 🙁

      Let me know if I can help.

      Dom

    Viewing 16 replies (of 16 total)