What you want seems very simple to me, you can do it this way:
- Create a class (file: Database.php) to access the database using PDO, as in the example below:
class Database {
 private static $servidor = 'localhost'; // Servidor, no caso poderia ser também localhost
 private static $usuario = 'u541106066_ctp'; // usuário do banco de dados
 private static $senha = 'jkf45s6f4sdf4'; // senha do banco de dados
 private static $banco = 'u541106066_estad'; // nome do banco de dados
 private static $instance = null;
 //inicia a conexão
  public static function getConnection() {
     if (!self::$instance instanceof PDO) {
         try {
             self::$instance = new PDO('mysql:host=' . 
             self::$servidor . ';dbname=' . 
             self::$banco, 
             self::$usuario, 
             self::$senha, 
             array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
         } catch (PDOException $exc) {
           echo "Erro ao conectar :: {$exc->getMessage()}";
         }
     } 
  return self::$instance;
  }
//metodo para trazer vários resultados
  public function fetchAll($query) {
     $con = self::getConnection();
     $stmt = $con->prepare($query);
     $this->execute($stmt);
     if ($stmt->rowCount()) {
        return $stmt->fetchAll(PDO::FETCH_OBJ);
     } else {
       return false;
     }
  }
//metodo para trazer um resultado
 public function fetch($query) {
    $con = self::getConnection();
    $stmt = $con->prepare($query);
    $this->execute($stmt);
    if ($stmt->rowCount()) {
         return $stmt->fetch(PDO::FETCH_OBJ);
    } else {
      return false;
    }
 }
 //executa o PDO
  public function execute(PDOStatement $stmt, array $data = null) {
     try {
           if (isset($data)) {
               $stmt->execute($data);
           } else {
           $stmt->execute();
           }
     } catch (PDOException $exc) {
       echo $exc->getTraceAsString();
       var_dump($exc->getMessage());
     }
  }
 //metodo para inserir e atualizar dados
  public function save($sql, array $data) {
     $con = self::getConnection();
     $stmt = $con->prepare($sql);
     $this->execute($stmt, $data);
     if ($stmt->rowCount()) {
        return true;
     } else {
       return false;
     }
  }
}
- Use the class to take the database data, create a file of type index.php and in this file do the following:
//primeiro você precisa incluir a classe
require_once("Database.php");
//agora você precisa instanciá-la:
$conexao = new Database();
/*
Agora basta chamar o método para a query que você quer buscar no seu banco, através da requisição GET.
- no seu caso /index.php?id=1
- Armazene numa variável o valor que receber
*/
$requisicao_consulta = (isset($_GET['id'])) ? $_GET['id'] : null;
//para post, salva a id no campo hidden 
$valor_id = ($_POST['id'] != '') ? $_POST['id'] : null;
//requisição de inclusão/atualização
$requisicao_save = (isset($_POST['action'])) ? $_POST['action'] : null;
if ($requisicao_save != null) {
    $values = [
       'id' => $valor_id,
       'val1' => $_POST['valor1'],
       'val2' => $_POST['valor2'],
       'val3' => $_POST['valor3'],
    ];
} else {
    if ($requisicao_consulta != null) {
        $data = $conexao->fetch("SELECT id,
                                        valor1,
                                        valor2,
                                        valor3 
                                 FROM   comandos
                                 WHERE  id='$requisicao_consulta'");
    }
    $message = "- Preencha o formulário abaixo:\n<br>";
    if (isset($_GET['success-insert'])) {
       $message .= "Dados cadastrados com sucesso!\n<br>";
    }
    if (isset($_GET['success-update'])) {
       $message .= "Dados atualizados com sucesso!\n<br>";
    }
}
//agora basta chamar a query com a requisição
if ($requisicao_save == 'insert' && $valor_id == null) {
   $execute = $conexao->save("INSERT INTO comandos
                              (id, valor1, valor2, valor3)
                              VALUES (:id,:val1,:val2,:val3);",
                              $values);
   header('Location: index.php?success-insert');
}
if ($requisicao_save == 'update' && $valor_id != null) {
   $execute = $conexao->save("UPDATE comandos SET
                              valor1=:val1,
                              valor2=:val2,
                              valor3=:val3
                              WHERE id:id;",
                              $values);
  header('Location: index.php?success-update');
}
//a variável $data representa os dados (em objeto) que contém o conjunto de valores trazido pela similaridade da sua requisição, como não é uma coleção, "não" utilizamos $conexao->fetchAll("..."), onde teríamos uma coleção em array. Desta maneira, vamos construir um formulário para preencher os dados que serão alterados (vou escrever em php mesmo, depois você refatora se achar melhor):  
$inputs = [];
$action = 'insert';
if (!empty($data)) {
    $action = 'update';
    foreach ($data as $key => $dado) {
    $inputs["<label>{ucwords($key)}</label>\n<input type=\"text\" value=\"{$dado->$key}\" name=\"{$key}\">"];
    }
    $inputs["<input type=\"hidden\" name=\"action\" value=\"update\">"];
} else {
    for ($i=1; $i <= 3; $i++) {
        $inputs["<label>Valor {$i}</label>\n<input type=\"text\" value=\"\" name=\"valor{$i}\">"];
    }
}
$inputs["<input type=\"hidden\" name=\"action\" value=\"{$action}\">"];
$inputs["<input type=\"hidden\" name=\"id\" value=\"{$valor_id}\">"];
$inputs["<input type=\"submit\" value=\"Salvar\">"];
echo "<div id=\"mensagem\" class=\"msg\">{$message}</div>\n";
echo "<form method=\"post\" action=\"{$_SERVER['SCRIPT_NAME']}\" name=\"send\" id=\"send\">\n";
echo implode("\n<br />", $inputs);
echo "</form>";
 
							
							
						 
Failed to execute sql.
– user6406
how so ? Could exemplify
– Carlos
I made an example for you Carlos, take a look... with the execution and fetch_array()
– Sr. André Baill
Another thing, what is the temporal aspect of this data? It should be saved in a relational database? ?
– user6406
There is error in the first code. I do not have much knowledge in my sql. What I need exactly is to put a piece of data on one page and output it on another page. These pages will be accessed from different customers. One will send the data and the other will pick it up. The data in question should be kept even when customers disconnect. This process must happen in real time and continuously.
– Carlos
Time to migrate to PDO :)
– Wallace Maxters
To make
SELECTyou have to use the function mysql_fetch_array, in the example you are just printing the query value, it is thus in the code?– deFreitas