Exemple #1
0
<?
//*********************************************************************
// CONFIGURAÇÃO DE BANCO DE DADOS
//*********************************************************************
//$con = mysql_connect($hostname_conn,$username_conn,$password_conn);
//$bd  = mysql_select_db($database_conn);
//*********************************************************************
// GERA A INSTRUÇÃO SQL E CHAMA A FUNÇÃO PARA GERAR AS COLUNAS
//*********************************************************************

$sql = $busqueda;

GeraColunas("6", $sql)
 ?>
<?
//*********************************************************************
// FUNÇÃO: GERACOLUNAS
// Parametros:
//  $pNumColunas (int)   > Quant. de colunas para distribuição
//  $pQuery    (string) > Query de registros
//*********************************************************************
function GeraColunas($pNumColunas, $pQuery) {
$resultado = mysql_query($pQuery);
echo ("<table width='100%' align='center' border='0'>\n");
 for($i = 0; $i <= mysql_num_rows($resultado); ++$i) {
 
 for ($intCont = 0; $intCont < $pNumColunas; $intCont++) {
  $linha = mysql_fetch_array($resultado);
  if ($i > $linha) {
   if ( $intCont < $pNumColunas-1) echo "</tr>\n";
   break;
include "Connections/conn.php";
//*********************************************************************
// CONFIGURAÇÃO DE BANCO DE DADOS
//*********************************************************************
$con = mysql_connect($hostname_conn, $username_conn, $password_conn);
$bd = mysql_select_db($database_conn);
?>
<table cellSpacing=1 cellPadding=0 width="50%" align=center border=0>
<tr>
 <td>
     <?php 
//*********************************************************************
// GERA A INSTRUÇÃO SQL E CHAMA A FUNÇÃO PARA GERAR AS COLUNAS
//*********************************************************************
$sql = "SELECT * FROM tbl_produtos ORDER BY RAND() LIMIT 0,4";
GeraColunas(2, $sql);
?>
</td>
</tr>
</table>
<?php 
//*********************************************************************
// FUNÇÃO: GERACOLUNAS
// Parametros:
//  $pNumColunas (int)   > Quant. de colunas para distribuição
//  $pQuery    (string) > Query de registros
//*********************************************************************
function GeraColunas($pNumColunas, $pQuery)
{
    $resultado = mysql_query($pQuery);
    echo "<table width='100%' border='0'>\n";