Ir para conteúdo
Fórum Script Brasil
  • 0

Criar uma Pagina mostrar varios campos


manogaucho

Pergunta

Tudo Bem!!!

Estou modificando um sistema que era de imobiliária para deixa-lo adaptável para necessidades de uma amiga, transformar em sistema igual ao leilão, onde ela cadastrará os produtos e os usuários ( Vendedores) entrarão e vão cadastrar no produtos seus preços, no final da semana ela pegara cada produto e verá qual o preço menor de cada e entrar em contato com o vendedor que fez a oferta, o sistema já quase pronto na parte de cadastro de categoria e produto e de cadastramento de usuário ( vendedor) de fato o que estou tentando criar é uma pagina que mostrar resultados de todos os produtos, a com o nome e valor oferecido por cada vendedor eu precisarei de alguns campos de 4 tabelas. Abaixo estão as 4 tabelas que falei, elas estão completas, mas não uso todos os campos, mas decidi colocar só para mostrar:

1ª tabela re2_categories campos: PRIMARY - CategoryName

2ª tabela re2_subcategories campos: SubcategoryID - SubcategoryName - CategoryID

3ª tabela re2_agents campos: AgentID - TipodeConta - username - password - FirstName -LastName - resume - phone - cellular - pager - ResumeImages - email - logo - RegDate – ExpDate- AccountStatus - PriorityLevel - offers - news - NewsletterType - days10 - days5 - days1

4ª tabela re2_listings campos: ListingID - AgentID - CategoryID - SubcategoryID - address city - state - country - ShortDesc - DetailedDesc - Price - PropertyType - neighbourhood - rooms - bathrooms - fireplace - garage - SquareMeters - LotSize - HomeAge - NearSchool - NearTransit - NearPark - OceanView - LakeView - MountainView - OceanWaterfront -LakeWaterfront - RiverWaterfront - image- DateAdded -visits

O sistema esta funcionando :

Na tabela 1 ( re2_categories) , transformei ela em e uma categoria para inserir dois dados um “ Produto: “ e outro “Ofertas do Cliente” , veja abaixo ( já está Funcionando )

CategoryID: 9

CategoryName: Produto:

CategoryID: 10

CategoryName: Ofertas do Vendedor

A tabela 2 ( re2_subcategories ) Mudei ela para inserir os produtos , para mostrar para os usuários ( vendedores) cadastrar seus preços, inserir 3 dados para dar um exemplo: ( já está Funcionando )

SubcategoryID: 21

SubcategoryName:Açucar Dolce

CategoryID: 9

SubcategoryID: 20

SubcategoryName:Sabão

CategoryID: 9

SubcategoryID: 24

SubcategoryName: Carvão

CategoryID: 10

Na tabela 3 ( re2_agents ) inserir 2 usuários ( 2 Vendedores) nos campos abaixo: Este é tabela de cadastro dos usuários do sistema: ( já está Funcionando )

AgentID : 21

FirstName : maninho

AgentID : 22

FirstName : mano

Agora a tabela 4 (re2_listings ), Fica os dados que os usuários cadastrarão seu preços nos produtos, cadastrei 2 preço para o mesmo produto de cada vendedor, com valores diferente, ficou assim Só coloquei os campos preenchidos no momento do cadastro do preço para o produto: ( já está Funcionando ),

ListingID:1

AgentID:21

CategoryID:9

SubcategoryID:21

Price:1.56

ListingID:3

AgentID:22

CategoryID:9

SubcategoryID:21

Price:1.22

Agora o que estou tentando criar, mas não estou conseguindo é um Select que mostre em uma única pagina a lista o nome de cada Produto que esta tabela re2_subcategories no campo SubcategoryName, e abaixo os nomes de cada vendedor que esta no campo FirstName da tabela re2_agents e o valor da sua oferta para o produto, este valor esta no campo Price da tabela re2_listings,na lista pode aparecer todos os produtos cadastrados, se tiver ou não oferta de um ou mais vendedores ele aparecerá abaixo do nome do produto com sua a oferta do lado do nome. Quero usar em apenas uma pagina, por que vai ser impresso no final, todos os produtos com suas ofertas, um grande detalhe é que o “ order by “ tem que ser pelo campo Price , para poder ficar o menor preço oferecido no topo dos preços de cada produto...Para informar, apaguei toda a pagina que mostrará este select, só tem um require_once("configuracao_mysql.php"); que faz a conexão ao banco de dados.

Abaixo esta o sql de toas as tabelas do sistema:

-- phpMyAdmin SQL Dump

-- version 3.2.4

-- http://www.phpmyadmin.net

--

-- Servidor: localhost

-- Tempo de Geração: Jun 30, 2010 as 02:01

-- Versão do Servidor: 5.1.41

-- Versão do PHP: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

--

-- Banco de Dados: `bate_bola`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_admin`

--

CREATE TABLE IF NOT EXISTS `re2_admin` (

`AdminID` varchar(50) NOT NULL,

`AdminPass` varchar(32) NOT NULL,

`AdminName` varchar(100) NOT NULL,

`AdminEmail` varchar(150) NOT NULL,

PRIMARY KEY (`AdminID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--

-- Extraindo dados da tabela `re2_admin`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_agents`

--

CREATE TABLE IF NOT EXISTS `re2_agents` (

`AgentID` int(10) NOT NULL AUTO_INCREMENT,

`TipodeConta` int(1) NOT NULL DEFAULT '0',

`username` varchar(50) NOT NULL,

`password` varchar(32) NOT NULL,

`FirstName` varchar(150) NOT NULL,

`LastName` varchar(150) NOT NULL,

`resume` text NOT NULL,

`phone` varchar(50) NOT NULL,

`cellular` varchar(50) NOT NULL,

`pager` varchar(50) NOT NULL,

`ResumeImages` text NOT NULL,

`email` varchar(150) NOT NULL,

`logo` varchar(255) NOT NULL,

`RegDate` int(10) NOT NULL DEFAULT '0',

`ExpDate` int(10) NOT NULL DEFAULT '0',

`AccountStatus` varchar(20) NOT NULL DEFAULT 'pending',

`PriorityLevel` int(1) NOT NULL DEFAULT '2',

`offers` int(3) NOT NULL DEFAULT '0',

`news` char(1) NOT NULL DEFAULT 'y',

`NewsletterType` varchar(10) NOT NULL DEFAULT 'plain',

`days10` char(1) NOT NULL DEFAULT 'n',

`days5` char(1) NOT NULL DEFAULT 'n',

`days1` char(1) NOT NULL DEFAULT 'n',

PRIMARY KEY (`AgentID`),

UNIQUE KEY `email` (`email`),

UNIQUE KEY `username` (`username`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_agents`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_banners`

--

CREATE TABLE IF NOT EXISTS `re2_banners` (

`ClientID` int(10) NOT NULL DEFAULT '0',

`BannerID` int(10) NOT NULL AUTO_INCREMENT,

`BannerURL` varchar(255) NOT NULL,

`BannerFile` varchar(255) NOT NULL,

`BannerAlt` varchar(255) NOT NULL,

`BannerType` varchar(50) NOT NULL,

`bCat` int(10) NOT NULL DEFAULT '0',

`bSub` int(10) NOT NULL DEFAULT '0',

PRIMARY KEY (`BannerID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_banners`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_categories`

--

CREATE TABLE IF NOT EXISTS `re2_categories` (

`CategoryID` int(10) NOT NULL AUTO_INCREMENT,

`CategoryName` varchar(255) NOT NULL,

PRIMARY KEY (`CategoryID`),

UNIQUE KEY `CategoryName` (`CategoryName`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_categories`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_listings`

--

CREATE TABLE IF NOT EXISTS `re2_listings` (

`ListingID` int(10) NOT NULL AUTO_INCREMENT,

`AgentID` int(10) NOT NULL DEFAULT '0',

`CategoryID` int(10) NOT NULL DEFAULT '0',

`SubcategoryID` int(10) NOT NULL DEFAULT '0',

`address` text NOT NULL,

`city` varchar(100) NOT NULL,

`state` varchar(100) NOT NULL,

`country` varchar(150) NOT NULL,

`ShortDesc` text NOT NULL,

`DetailedDesc` text NOT NULL,

`Price` float(15,2) NOT NULL DEFAULT '0.00',

`PropertyType` varchar(50) NOT NULL,

`neighbourhood` text NOT NULL,

`rooms` int(2) NOT NULL DEFAULT '0',

`bathrooms` int(2) NOT NULL DEFAULT '0',

`fireplace` char(1) NOT NULL DEFAULT 'n',

`garage` int(2) NOT NULL DEFAULT '0',

`SquareMeters` float(15,2) NOT NULL DEFAULT '0.00',

`LotSize` float(15,2) NOT NULL DEFAULT '0.00',

`HomeAge` int(3) NOT NULL DEFAULT '0',

`NearSchool` char(1) NOT NULL DEFAULT 'n',

`NearTransit` char(1) NOT NULL DEFAULT 'n',

`NearPark` char(1) NOT NULL DEFAULT 'n',

`OceanView` char(1) NOT NULL DEFAULT 'n',

`LakeView` char(1) NOT NULL DEFAULT 'n',

`MountainView` char(1) NOT NULL DEFAULT 'n',

`OceanWaterfront` char(1) NOT NULL DEFAULT 'n',

`LakeWaterfront` char(1) NOT NULL DEFAULT 'n',

`RiverWaterfront` char(1) NOT NULL DEFAULT 'n',

`image` text NOT NULL,

`DateAdded` int(10) NOT NULL DEFAULT '0',

`visits` int(10) NOT NULL DEFAULT '0',

PRIMARY KEY (`ListingID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_listings`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_mail_archive`

--

CREATE TABLE IF NOT EXISTS `re2_mail_archive` (

`subject` varchar(255) NOT NULL,

`message` text,

`MailDate` int(10) NOT NULL DEFAULT '0'

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--

-- Extraindo dados da tabela `re2_mail_archive`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_prices`

--

CREATE TABLE IF NOT EXISTS `re2_prices` (

`PackageName` varchar(50) NOT NULL,

`PriceID` int(10) NOT NULL AUTO_INCREMENT,

`PriceValue` float(5,2) NOT NULL DEFAULT '0.00',

`Duration` varchar(10) NOT NULL,

`PriorityLevel` int(1) NOT NULL DEFAULT '0',

`PriceType` varchar(10) NOT NULL DEFAULT '0',

`offers` int(10) NOT NULL DEFAULT '0',

PRIMARY KEY (`PriceID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_prices`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_priority`

--

CREATE TABLE IF NOT EXISTS `re2_priority` (

`PriorityID` int(10) NOT NULL AUTO_INCREMENT,

`PriorityName` varchar(50) NOT NULL,

`PriorityLevel` int(1) NOT NULL DEFAULT '0',

PRIMARY KEY (`PriorityID`),

UNIQUE KEY `PriorityName` (`PriorityName`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_priority`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_settings`

--

CREATE TABLE IF NOT EXISTS `re2_settings` (

`id` int(1) NOT NULL DEFAULT '0',

`SiteTitle` varchar(255) NOT NULL,

`SiteName` varchar(255) NOT NULL,

`SiteKeywords` varchar(255) NOT NULL,

`SiteDescription` text,

`ContactEmail` varchar(150) NOT NULL,

`CompanyAddress` text,

`PayPalEmail` varchar(150) NOT NULL,

`SellerID` int(5) NOT NULL DEFAULT '0',

`Agreement` text NOT NULL,

`sp_vendor_email` varchar(255) NOT NULL,

`sp_payee_email` varchar(255) NOT NULL,

`sp_secret_code` varchar(255) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--

-- Extraindo dados da tabela `re2_settings`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_stats`

--

CREATE TABLE IF NOT EXISTS `re2_stats` (

`BannerID` int(10) NOT NULL DEFAULT '0',

`impressions` int(10) NOT NULL DEFAULT '0',

`clicks` int(10) NOT NULL DEFAULT '0',

`mydate` int(10) NOT NULL DEFAULT '0',

`ip` varchar(50) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--

-- Extraindo dados da tabela `re2_stats`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_subcategories`

--

CREATE TABLE IF NOT EXISTS `re2_subcategories` (

`SubcategoryID` int(10) NOT NULL AUTO_INCREMENT,

`SubcategoryName` varchar(255) NOT NULL,

`CategoryID` int(10) NOT NULL DEFAULT '0',

PRIMARY KEY (`SubcategoryID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_subcategories`

--

-- --------------------------------------------------------

--

-- Estrutura da tabela `re2_types`

--

CREATE TABLE IF NOT EXISTS `re2_types` (

`TypeID` int(10) NOT NULL AUTO_INCREMENT,

`TypeName` varchar(100) NOT NULL,

PRIMARY KEY (`TypeID`),

UNIQUE KEY `TypeName` (`TypeName`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--

-- Extraindo dados da tabela `re2_types`

--

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Desde já agradeço a ajuda.

Obrigado!!!

Editado por manogaucho
Remover palavra "ajuda" do título conforme regra 3.6 (Jonathan)
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Tenho um Script rodando em outro sistema e tem uma pagina que lista do jeito que falei...

Estou mandando o codigo da pagina que lista:

<?php


    // show whole price list

function pricessCategories($parent,$level)
{

    //same as processCategories(), except it creates a pricelist of the shop

    $out = array();
    $cnt = 0;

    $q1 = db_query("select categoryID, name from ".CATEGORIES_TABLE." where parent=$parent order by name") or die (db_error());
    while ($row = db_fetch_row($q1))
    {

        //define back color of the cell
        $r = hexdec(substr(CONF_LIGHT_COLOR, 0, 2)); 
        $g = hexdec(substr(CONF_LIGHT_COLOR, 2, 2)); 
        $b = hexdec(substr(CONF_LIGHT_COLOR, 4, 2)); 
        $m = (float)max($r, max($g,$b));
        $r = round((190+20*min($level,3))*$r/$m);
        $g = round((190+20*min($level,3))*$g/$m);
        $b = round((190+20*min($level,3))*$b/$m);
        $c = dechex($r).dechex($g).dechex($b); //final color

        //add category to the output
        $out[$cnt][0] = $row[0];
        $out[$cnt][1] = $row[1];
        $out[$cnt][2] = $level;
        $out[$cnt][3] = $c;
        $out[$cnt][4] = 0; //0 is for category, 1 - product
        $cnt++;

        //add products
        $q = db_query("select productID, name, Price from ".PRODUCTS_TABLE." where categoryID=".$row[0]." and Price>0 and enabled=1 order by Price") or die (db_error());
        while ($row1 = db_fetch_row($q))
         {
            if ($row1[2] <= 0)
                $row1[2]= "n/a";
            else
                $row1[2] = show_price($row1[2]);

            //add product to the output
            $out[$cnt][0] = $row1[0];
            $out[$cnt][1] = $row1[1];
            $out[$cnt][2] = $level;
            $out[$cnt][3] = "FFFFFF";
            $out[$cnt][4] = 1; //0 is for category, 1 - product
            $out[$cnt][5] = $row1[2];
            $cnt++;

         }

        //process all subcategories
        $sub_out = pricessCategories($row[0], $level+1);

        //add $sub_out to the end of $out
        for ($j=0; $j<count($sub_out); $j++)
        {
            $out[] = $sub_out[$j];
            $cnt++;
        }
     }

    return $out;

} //pricessCategories



    if (isset($_GET["show_price"])) //show pricelist
    {
        $pricelist_elements = pricessCategories(0, 0);
        $smarty->assign("pricelist_elements", $pricelist_elements);
        $smarty->assign("main_content_template", "pricelist.tpl.html");
    }

?>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...