Zaloguj | Zarejestruj | FAQ
Anonymous

echoing to screen without overwriting existing echo

+ Odpowiedz

Posty: 4 Strona 1 z 1


echoing to screen without overwriting existing echo

przez rascalsailor » Pn lip 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

Kod: Zaznacz cały
<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 użytkownika

rascalsailor

  • Posty: 1
  • Dołączył(a): Pn lip 02, 2018 9:55 am

Re: echoing to screen without overwriting existing echo

przez Caddy02 » Pn gru 17, 2018 1:52 pm

rascalsailor napisał(a):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

Kod: Zaznacz cały
<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 użytkownika

Caddy02

  • Posty: 1
  • Dołączył(a): Pn gru 17, 2018 1:48 pm

Re: echoing to screen without overwriting existing echo

przez martix002 » Pn lut 04, 2019 8:38 pm

Caddy02 napisał(a):
rascalsailor napisał(a):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 użytkownika

martix002

  • Posty: 1
  • Dołączył(a): Pn lut 04, 2019 8:33 pm

Re: echoing to screen without overwriting existing echo

przez horeakaii » Śr maja 22, 2019 3:23 pm

You can print over an existing line using the carriage return character ('\r'). This post, while about creating a progress bar, should cover how to use carriage returns to overwrite existing lines.

change-of-address-form-online.com
Avatar użytkownika

horeakaii

  • Posty: 19
  • Dołączył(a): Pn kwi 29, 2019 1:19 pm


+ Odpowiedz

Strona 1 z 1