Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Paulo1016

Erro na Paginação na Vitrine Virtual ?

Recommended Posts

Erro na Paginação na Vitrine Virtual ? O que estou fazendo errado?

<?php
$consulta = mysql_connect('localhost', 'root', 'vertrigo');
$db = mysql_select_db('banca', $consulta);

mysql_set_charset('utf8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vitrine</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<div id="conteudo">

<?php
function paginacao($query, $quantidade, $pag, $p) {
    $conn = mysqli_connect(HOST, USER, PASS, DB);
    $qr_all = mysqli_query($conn, $query) or die(mysqli_error($conn));
    $total_registros = mysqli_num_rows($qr_all);
    if ($total_registros > $quantidade) {
        $pags = ceil($total_registros / $quantidade);
        $max_links = 10;
        echo '<ul id="paginacao">' . PHP_EOL;
        echo "<li><a href='" . $pag . "1/' title='Próximo' target='_self'>Primeira</a></li>" . PHP_EOL;
        for ($i = $p - $max_links; $i <= $p - 1; $i++) {
            if ($i <= 0) {
                
            } else {
                echo "<li><a href='" . $pag . $i . "/' target='_self'>" . $i . "</a></li>" . PHP_EOL;
            }
        }
        echo "<li><a class='paginacaoAtiva'>" . $p . "</a></li>" . PHP_EOL;
        for ($i = $p + 1; $i <= $p + $max_links; $i++) {
            if ($i > $pags) {
                
            } else {
                echo "<li><a href='" . $pag . $i . "/' target='_self'>" . $i . "</a></li>" . PHP_EOL;
            }
        }
        echo "<li><a href='" . $pag . $pags . "/' title='Anterior' target='_self'>Última</a></li>" . PHP_EOL;
        echo '</ul>';
    }
}
?>

<table cellpadding="8" cellspacing="10" border="0" width="100%">
	<tr><?php
		$loop = 3;

$p = (isset($_GET["p"])) ? filter_input(INPUT_GET, 'p', FILTER_SANITIZE_NUMBER_INT) : 1;
$pag = URL . 'SUA_PAGINA.php/' . $p . '/';
$quantidade = 9;
$inicio = ($p * $quantidade) - $quantidade;
$fim = $inicio + $quantidade;
$query = "SELECT * FROM `SUA_TABELA`";
$sql = $query . " ORDER BY `ORDEM` ASC LIMIT " . $inicio . "," . $fim;

		$i = 1;
		while($ln = mysql_fetch_array($query)){
			if($i < $loop){
			echo '
			 <td valign="top" align="center" bgcolor="f4f4f4"><img src="'.$ln['caminho'].$ln['foto'].'" width="200px" alt="" /> </td>
			 ';	
			}elseif($i = $loop){
				echo '
				 <td valign="top" align="center" bgcolor="f4f4f4"><img src="'.$ln['caminho'].$ln['foto'].'" width="200px" alt="" /></td></tr>
				 <tr>
			 ';
			 $i = 0;		
			}
		$i++;	
		}
	?>
    <td valign="top" align="center" bgcolor="f4f4f4"><img src="imagens/01.png" width="200px" alt="" /></td>
    </tr>
</table>

<?php
paginacao($query, $quantidade, $pag, $p);
?>

</div>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\VertrigoServ\www\bancadejornalerevista\teste.php on line 62

01.png

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2005): Unknown MySQL server host 'HOST' (11004) in C:\Program Files\VertrigoServ\www\bancadejornalerevista\teste.php on line 20

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\Program Files\VertrigoServ\www\bancadejornalerevista\teste.php on line 21

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\Program Files\VertrigoServ\www\bancadejornalerevista\teste.php on line 21

 

 

Failed to load resource: the server responded with a status of 404 (Not Found)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.