O código:
<?php require_once('Connections/conecta.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}$colname_resultado = "-1";if (isset($_GET['cod'])) { $colname_resultado = (get_magic_quotes_gpc()) ? $_GET['cod'] : addslashes($_GET['cod']);}$i=$i + 0;$max=50; mysql_select_db($database_conecta, $conecta);$query_resultado = "SELECT * FROM page2 WHERE categoria = $categoria order by titulo asc";$resultado = mysql_query($query_resultado, $conecta) or die(mysql_error());$row_resultado = mysql_fetch_assoc($resultado);$totalRows_resultado = mysql_num_rows($resultado);$colname_seleciona_pag = "-1";if (isset($_GET['cod'])) { $colname_seleciona_pag = $_GET['cod'];}mysql_select_db($database_conecta, $conecta);$query_seleciona_pag = sprintf("SELECT * FROM page2 WHERE categoria = $categoria", GetSQLValueString($colname_seleciona_pag, "text"));$seleciona_pag = mysql_query($query_seleciona_pag, $conecta) or die(mysql_error());$row_seleciona_pag = mysql_fetch_assoc($seleciona_pag);$totalRows_seleciona_pag = mysql_num_rows($seleciona_pag);$colname_seleciona_menu = "-1";if (isset($_GET['cod'])) { $colname_seleciona_menu = $_GET['cod'];}?>E entre head:
<?php if ($totalRows_seleciona_pag > 0) { // Show if recordset not empty ?> <div align="justify"></div> <?php } // Show if recordset not empty ?></td> </tr> <tr> <td align="center" valign="top"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" id="gallery"> <tr> <td valign="top"></td> </tr> <tr> <td width="544" align="center" valign="top"><div id="box"> <? mysql_select_db($database_conecta, $conecta);if(!empty($HTTP_POST_VARS[palavra])) { $palavra = str_replace(" ", "%", $HTTP_POST_VARS[palavra]); /* Altera os espaços adicionando no lugar o simbolo % */ $qr = "SELECT * FROM page2 WHERE texto LIKE '%".$palavra."%'"; $sql = mysql_query($qr); // Executa a query no Banco de Dados $total = mysql_num_rows($sql); // Conta o total ded resultados encontrados while($r = mysql_fetch_array($sql)) { // Gera o Loop com os resultados echo "<p></p>\n"; echo $r[texto2]."\n"; echo "<strong>-</strong>\n"; echo $r[titulo]."<br>\n"; echo "<img width=150 src="; echo $r[foto]."\n"; echo "<br></br>\n"; echo "<strong>Descrição :</strong>\n"; echo $r[texto]."<br>\n"; echo "<p></p>\n"; } } ?> <?php$colunas="5"; $cont="1"; print"<table width='99%'>";while ($linha=mysql_fetch_array($resultado)) {$nome = $linha["foto"];$res_titulo = $linha["titulo"];$res_foto = $linha["foto"];$res_codigo = $linha["codigo"];$res_texto = $linha["texto"];$res_pula_linha = $linha["<br/>"]; if($cont==1){print"<tr>";}print"<td>";print "<div align=center><a href=produto.php?cod=$res_codigo rel=milkbox:gall1 title='$res_titulo'><img src=thumb.php?".$res_foto." class=imagem alt=$res_titulo oncontextmenu=return false align=top border=0 /></div></a>\n"; print "<div align=center class=texto06>".$res_titulo."</div>";//aqui printa o resultadoprint "<div align=center ><a href=produto.php?cod=$res_codigo rel=milkbox:gall2 title='$res_titulo'><img src=images/detalhes.jpg oncontextmenu=return false border=0 class=imagem alt=Ver detalhes do produto/></div></a><br>\n"; print"</td>"; if($cont==$colunas){ print"</tr>"; $cont=0; } $cont=$cont+1; } if(!$cont==$colunas){ print"</tr></table>"; } else { print "</table>";}?> <?phpmysql_free_result($resultado);mysql_free_result($seleciona_pag);?></div>
Link da página:
http://www.ideiaseid...php?categoria=1
Edição feita por: Dudu, 25/04/2009, 18:45.
Utilize [codebox][/codebox] nos códigos