Jump to content

Ronald245

New Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Ronald245

  1. hi everyone, im new to these forums.

     

    as part of a project i'm working on i'm building a website for a large airline,

    i've had my ajax working perfectly but when i logged in on the site this morning it didnt update the <div>

     

    code on the page

    <div align="center">
    <button class="buttonup" type="button" onclick="tempup()"></button>
    <script language="javascript">
    function tempup() {
    $("#targettemp").load("targettemp.php");
    $.ajax({
    url: "tempup.php", //the page containing php script
    type: "POST", //request type
    })
    $(document).ready(function () {
    $("#targettemp").load("targettemp.php");
    });
    }
    </script>
    
    <h4 class="target-temp panel-body" id="targettemp ">
    <?php
    require 'dbconnection.php';
    $con;
    $dbcon;
    $temp = "SELECT `target temp` FROM Temperature WHERE homeid = 'BG0001' ";
    $query = mysql_query($temp);
    $results = mysql_result($query, 0);
    echo "$results ℃";
    ?>
    </h4>
    
    <div align="center">
                            <button class="buttondown" type="button" onclick="tempdwn()"></button>
                            <script language="javascript">
    function tempdwn() {
    $("#targettemp").load("targettemp.php");
    $.ajax({
    url: "tempdwn.php", //the page containing php script
    type: "POST", //request type
    })
    $(document).ready(function () {
    $("#targettemp").load("targettemp.php");
    });
    }
                            </script>
    </div>
    </div>
    
    
    

    tempdwn.php

     

     <?php
         require 'dbconnection.php';
            $con;
            $dbcon;
            $query = mysql_query("SELECT `target temp` FROM `Temperature` WHERE homeid = 'BG0001' ");
            $huidigetemp = mysql_result($query, 0);               
            $newtemp = $huidigetemp - 1;
            mysql_query("UPDATE Temperature SET `target temp`= $newtemp WHERE homeid = 'BG0001'  ");
            ?>
    

     

    targettemp.php:

     

    <?php  
    require 'dbconnection.php';
                    $con;
                    $dbcon;
    
                    $temp = "SELECT `target temp` FROM Temperature WHERE homeid = 'BG0001' ";
                    $query = mysql_query($temp);
                    $results = mysql_result($query, 0);
                    echo "$results ℃";
                    ?>
                    
     
    
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.