0
I’m starting in Pdo now, so will start the games for me a little bit and my question is the following: I am working on another code of a friend and in his code the get to display the information is taken the values by id, but I want the information to be searched by another column "code" and I could not make this change, can help me. The code is as follows::
require 'conexao.php';
// Recebe o id do cliente do cliente via GET
$id_cliente = (isset($_GET['id'])) ? $_GET['id'] : '';
// Valida se existe um id e se ele é numérico
if (!empty($id_cliente) && is_numeric($id_cliente)):
// Captura os dados do cliente solicitado
$conexao = conexao::getInstance();
$sql = 'SELECT id, codigo, nome, cursos, data_inicio, data_termino, horas FROM tab_clientes WHERE id = :id LIMIT 1';
$stm = $conexao->prepare($sql);
$stm->bindValue(':id', $id_cliente);
$stm->execute();
$cliente = $stm->fetch(PDO::FETCH_OBJ);
endif;
in the url looks like this: http://localhost/rm/certificate/system/print.php? id=1
but it should stay that way: http://localhost/rm/certificate/system/print.php? code=169fe1d7227
Help me over there please.
What code you call this page from select?
– MagicHat
Start by changing
$_GET['id']
for$_GET['codigo']
. The excerpt:if (!empty($id_cliente) && is_numeric($id_cliente)):
does not match the comment. Usefilter_input
instead of asking the value via$_GET
straightforward.– Maurivan