Changing PHP URL

Asked

Viewed 37 times

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 this WHERE 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.

  • Got it, thanks for the help.

  • How did you do?

  • How did you do it? The second consultation is not doing you any good.

  • 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&#xA; require_once('conexao.php');&#xA;&#xA; $LK = $_GET['LK'];&#xA;&#xA; $Valor_link = "SELECT Nome,Data,Codigo FROM Cadastro WHERE Nome LIKE '$LK'";&#xA; $resultado_encontrado = mysqli_query($conex, $Valor_link);&#xA; &#xA; if(mysqli_num_rows($resultado_encontrado) <= 0){&#xA; echo "Nada foi encontrado";&#xA; }&#xA; else{&#xA; while ($Cad = mysqli_fetch_array($resultado_encontrado)){&#xA; echo '<h2>'.$Cad['Nome'].'</h2>';&#xA; }&#xA; }&#xA; ?>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.