0
I need to enter the ID variable in the Client.php class to send it to the Server.php class that will search the product in the Database and show it again in the Client.php. Only that I’m having difficulty inserting the variable in the query of the function that will do the search in the Database.
Follow the class I’ve done.
Client class.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 class.php
$pesquisa = $_REQUEST["pesquisa"];
`$query = 'SELECT * FROM produtos where id = '.$pesquisa`;
I want to pass this query to the execute() function, to return it to the Client Class.php
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;
}
Where does this property come from
sql
of functionexecutar
? Not declared in the property scope of class– Wallace Maxters