Jump to content
Fórum Script Brasil
  • 0

[RESOLVIDO]Como listar produtos de varias categorias


XIM

Question

Bom dia amigos,como faço pra listar produtos de varias categorias na mesma pagina,tenho este script aqui,mas ele só lista de uma categoria,se puderem ajudar ficarei muito agradecido.

desde já agradeço a todos.

<?php require_once('Connections/conexao.php'); ?>

<?php

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_Recordset1 = 10;

$pageNum_Recordset1 = 0;

if (isset($_GET['pageNum_Recordset1'])) {

$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];

}

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "1";

if (isset($_GET['cod_cat'])) {

$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['cod_cat'] : addslashes($_GET['cod_cat']);

}

mysql_select_db($database_conexao, $conexao);

$query_Recordset1 = sprintf("SELECT * FROM produtos WHERE cod_cat = %s", $colname_Recordset1);

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);

$Recordset1 = mysql_query($query_limit_Recordset1, $conexao) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {

$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];

} else {

$all_Recordset1 = mysql_query($query_Recordset1);

$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);

}

$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

$queryString_Recordset1 = "";

if (!empty($_SERVER['QUERY_STRING'])) {

$params = explode("&", $_SERVER['QUERY_STRING']);

$newParams = array();

foreach ($params as $param) {

if (stristr($param, "pageNum_Recordset1") == false &&

stristr($param, "totalRows_Recordset1") == false) {

array_push($newParams, $param);

}

}

if (count($newParams) != 0) {

$queryString_Recordset1 = "&" . implode("&", $newParams);

}

}

$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);

?>

&lt;script language=JavaScript" type="text/JavaScript">

<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0

window.open(theURL,winName,features);

}

//-->

</script>

<div align="center">

<?php if ($totalRows_Recordset1 == 0) { // Show if recordset empty ?>

No momento n&atilde;o dispomos de nenhum produto para essa categoria.

<?php } // Show if recordset empty ?>

<br>

<?php do { ?>

<?php if ($totalRows_Recordset1 > 0) { // Show if recordset not empty ?>

<?php

$cont = "0";

echo "<table width=\"88%\" height=\"10\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">

<tr>"; //Inicia a tabela

while($row_Recordset1 = mysql_fetch_assoc($Recordset1)){

if($cont == "3"){

echo "</tr><tr>";

$cont = "0";}

echo "<td align=center ><img src='".$row_Recordset1['fot_peq]."' width='150' height='150' border='0'><br>";

echo $row_Recordset1['nome_prod']."<br>";

echo $row_Recordset1['descricao']."<br>";

echo '<a href=detalhes.php?cod_prod='.$row_Recordset1['cod_prod].'">Ver Detalhes</a>';

echo "</td>";

$cont++;

}

?>

Edited by XIM
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...