0
Personal I have a pagination system that to each page it pulls a content from the database.
In this case it pulls the ID "ID of each element of my database", I’m trying to change it to take the field " Name " from my database but I’m not getting, would someone explain me ?
<?php
$Pagina = (isset($_GET['cadastro'])) ? $_GET['cadastro'] : 1;
$BancoD = "SELECT * FROM cadastro ORDER BY id ASC";
$Val = mysqli_query($conexao,$BancoD);
$Total = mysqli_num_rows($Val);
$Quantidade = 1;
$NumeroPagina = ceil($Total/$Quantidade);
$PaginaInicial = ($Quantidade*$Pagina)-$Quantidade;
$Bancod = "SELECT * FROM cadastro ORDER BY id ASC LIMIT $PaginaInicial,$Quantidade";
$Val= mysqli_query($conexao,$BancoD);
$Total = mysqli_num_rows($Val);
while ($NovelPost = mysqli_fetch_array($Val)){
echo $NovelPost['Nome'];
echo $NovelPost['Idade'];
echo $NovelPost['Cidade'];
echo $NovelPost['Codigo'];
}
?>
I’ve tried using the WHERE Nome=$Pagina
but I couldn’t.
What data exists in the column
nome
? Jose, Paula, Ana, Maria etcc?$Pagina
by what is seen in the code returns a number, so thisWHERE Nome=$Pagina
does not happen. To take the name you have to pass some name` via POST or GET and query with this data received.– user60252
Got it, thanks for the help.
– EDGNoizy
How did you do?
– user60252
How did you do it? The second consultation is not doing you any good.
– user60252
I made a new script, but I got the current url with a GET dps just had it search the database for the existing GET values.
<?php
 require_once('conexao.php');

 $LK = $_GET['LK'];

 $Valor_link = "SELECT Nome,Data,Codigo FROM Cadastro WHERE Nome LIKE '$LK'";
 $resultado_encontrado = mysqli_query($conex, $Valor_link);
 
 if(mysqli_num_rows($resultado_encontrado) <= 0){
 echo "Nada foi encontrado";
 }
 else{
 while ($Cad = mysqli_fetch_array($resultado_encontrado)){
 echo '<h2>'.$Cad['Nome'].'</h2>';
 }
 }
 ?>
– EDGNoizy