Connexion | Inscription | FAQ
Anonymous

echoing to screen without overwriting existing echo

+ Publier une réponse

3 messages Page 1 sur 1


echoing to screen without overwriting existing echo

par rascalsailor » Lun Juil 02, 2018 10:06 am

Hi all. (sorry if this should be in HTML forum - I figure it's a bit of both) I'm new to PHP/HTML and would like to print to screen the led status, but it keeps replacing (overwriting the existing text). So it only displays the "Led is on (or off)" message or it only shows "Pin value is" message but not both together. After the screen button is clicked.
So I'd like to keep the words "Led is on" or "Led is off" and next to this (or even below this) add the status words - "Pin value =" when the status key is pressed without the existing "Led =" message text disappearing.

Here is the code - and thanks

Code: Tout sélectionner
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>LED Control</title>
</head>
        <body>
        LED Control:
        <form method="get" action="gpio.php">
                <input type="submit" value="ON" name="on">
                <input type="submit" value="OFF" name="off">
                <input type="submit" value="Pin Status" name="status">
        </form>
        <?php
        $setmode = shell_exec("gpio -g mode 4 out");
        if(isset($_GET['on'])){
                $gpio_on = shell_exec("gpio -g write 4 0");
                echo "LED is on";
        }
        else if(isset($_GET['off'])){
                $gpio_off = shell_exec("gpio -g write 4 1");
                echo "LED is off";   
        }
        else if(isset($_GET['status'])){
       echo'<br>';
       echo"Pin Value = ";
            echo exec("gpio read 7");   
        }


        ?>
        </body>
</html>
Avatar de l’utilisateur

rascalsailor

  • Messages: 1
  • Inscrit le: Lun Juil 02, 2018 9:55 am

Re: echoing to screen without overwriting existing echo

par Caddy02 » Lun Déc 17, 2018 1:52 pm

rascalsailor a écrit:Hi all. (sorry if this should be in HTML forum - I figure it's a bit of both) I'm new to PHP/HTML and would like to print to screen the led status, but it keeps replacing (overwriting the existing text). So it only displays the "Led is on (or off)" message or it only shows "Pin value is" message but not both together. After the screen button is clicked.
So I'd like to keep the words "Led is on" or "Led is off" and next to this (or even below this) add the status words - "Pin value =" when the status key is pressed without the existing "Led =" message text disappearing.

Here is the code - and thanks

Code: Tout sélectionner
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>LED Control</title>
</head>
        <body>
        LED Control:
        <form method="get" action="gpio.php">
                <input type="submit" value="ON" name="on">
                <input type="submit" value="OFF" name="off">
                <input type="submit" value="Pin Status" name="status">
        </form>
        <?php
        $setmode = shell_exec("gpio -g mode 4 out");
        if(isset($_GET['on'])){
                $gpio_on = shell_exec("gpio -g write 4 0");
                echo "LED is on";[url=http://www.rachat-de-credit-simulation.com/budget-surendettement] obtenir prêt [/url]
        }
        else if(isset($_GET['off'])){
                $gpio_off = shell_exec("gpio -g write 4 1");
                echo "LED is off";   
        }
        else if(isset($_GET['status'])){
       echo'<br>';
       echo"Pin Value = ";
            echo exec("gpio read 7");   
        }


        ?>
        </body>
</html>

All things seem alright
Avatar de l’utilisateur

Caddy02

  • Messages: 1
  • Inscrit le: Lun Déc 17, 2018 1:48 pm

Re: echoing to screen without overwriting existing echo

par martix002 » Lun Fév 04, 2019 8:38 pm

Caddy02 a écrit:
rascalsailor a écrit:Hi all. (sorry if this should be in HTML forum - I figure it's a bit of both) I'm new to PHP/HTML and would like to print to screen the led status, but it keeps replacing (overwriting the existing text). So it only displays the "Led is on (or off)" message or it only meilleurs credits perso shows "Pin value is" message but not both together. After the screen button is clicked.
So I'd like to keep the words "Led is on" or "Led is off" and next to this (or even below this) add the status words - "Pin value =" when the status key is pressed without the existing "Led =" message text disappearing.

This is nice but if your are a beginner you couldn't understand it!
Thanks!
Avatar de l’utilisateur

martix002

  • Messages: 1
  • Inscrit le: Lun Fév 04, 2019 8:33 pm


+ Publier une réponse

Page 1 sur 1