-1
How can I do a function with this code, since I will have to repeat it several times and the only things that change are the variables $a and $b. I need to use in my html the return of the two resulting variables ($title and $subtitle).
$situacao = 0;
$sql = "SELECT * FROM `ed_painel` where (idaluno = '$id' or idaluno = '$id2') and a = '$a' and b ='$b' ;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$situacao = $row["situacao"];
$obs = $row["obs"];
} }
if ($situacao > 3 and $situacao < 7) {
$titulo = "AGUARDE"; }
else {
$titulo = "PENDENTE";
$subtitulo = '$obs';
}
I know it’s not like that, but it would be something like that:
funcaoteste (1,2) //variáveis $a e $b
<h1> $titulo </h1> <br>
<h2> $subtitulo </h2> <br>
funcaoteste (7,3) //variáveis $a e $b
<h1> $titulo </h1> <br>
<h2> $subtitulo </h2> <br>
funcaoteste (4,1) //variáveis $a e $b
<h1> $titulo </h1> <br>
<h2> $subtitulo </h2> <br>
Hey, buddy, thanks for helping out. When testing, I come across the following error: Fatal error: Uncaught Error: Call to a Member Function query() on null in .... on line 59. Have any idea what might be?
– Navegador
@Browser I just copy your own code, the line should be the
$result = $conn->query($sql);
, you must define the$conn
, as well as the$id
and$id2
.– Inkeliz
Perfect friend, it really was that, thank you very much.
– Navegador