I need to type the variable ID in the class Client.php so that it sends to the class Server.php that will search the product in the Database and show again in the Client.php. I'm having difficulty inserting the variable in the query of the function that will search the database.
Follow the class I've done.
Class Cliente.php
<form action="servidor.php" method="post">
Pesquisa: <input type="text" name="pesquisa" />
<input type="submit" />
</form>
<?php
include('servidor.php');
$connect = new servidor();
$connect->conectar();
$connect->selecionarDB();
?>
Server.php class
$pesquisa = $_REQUEST["pesquisa"];
'$query = 'SELECT * FROM produtos where id = '.$pesquisa';
I want to pass this query to the execute () function, so that it returns to the Client.php class
class servidor {
private $host = localhost;
private $bd = banco;
private $usuario = root;
private $senha = senha;
function conectar(){
$conexao = mysql_connect($this->host,$this->usuario,$this->senha) or die($this->mensagem(mysql_error()));
return $conexao;
}
function selecionarDB(){
$banco = mysql_select_db($this->bd) or die($this->mensagem(mysql_error()));
if($banco){
return true;
}else{
return false;
}
}
function executar(){
$query = mysql_query($this->sql) or die ($this->mensagem(mysql_error()));
return $query;
}