Ir para


Aviso aos navegantes: O PHPMania está com novidades e esperamos que gostem. Caso encontrem algum erro, ou tenham alguma dúvida e/ou sugestão crie um tópico clicando aqui.

Criar array e inserir dados em table

php array table

  • Please log in to reply
2 replies to this topic

#1 Lorrana

Lorrana

    Novato

  • Membros
  • Pip
  • 2 Posts:

Postou 22 maio 2016 - 05:52


Pessoal, sou iniciante em php e estou precisando de ajuda.
Como faço para pegar o input de um usuário, adicioná-lo em um array e exibi-lo em uma table?

Tenho esse código:



    <form  method = "post">
        <div class="form-group">
            <label style="margin-left: 35px;">• Produto </label>
            
                
                    <select id="cboProduto" name= "produto" style="margin-left: 45px; width: 210px; height: 30px;padding-left:8px;">
                    <?php
                        $query = 'SELECT * from tab_produto where flag_produto LIKE "venda" order by nome_produto';
                        $result = mysql_query($query) or die("Falha na execução da consulta");
                        while($row1 = mysql_fetch_assoc($result))
                        {                
                            $produto = $row1['id_produto'];
                            $nomeproduto = $row1['nome_produto'];
                    ?>                        
                            <option value="<?php echo $produto;?>"><?php echo $nomeproduto;?></option>
                            <?php
                        }     ?>    
                    </select>
                    
                    
                    <?php
                        $sql = "SELECT * FROM tab_produto WHERE id_produto = '$produto'";
                        $rs = mysql_query($sql);        
                        while($reg = mysql_fetch_array($rs))
                        {    
                            $produtos[] = array('nome_produto' => $reg['nome_produto'], 'valor_produto' => $reg['valor_produto']);
                        }
                    ?>

            <label style="margin-left: 35px;">• Quantidade</label>
            <td><input style="margin-left: 15px; width: 100px; height: 30px;padding-left:10px;" name="quantidade" type="text" id="txtQuant" >
            <button class="btn btn-primary" style="margin-left: 15px" type="submit" id="btnAdicionar"> + </button>
            <a href="EfetuarVenda.php" class="btn btn-danger" role="button">Nova Venda</a>
            
        </div>                
    </form>
            
    
    <hr>
        <div class="container"style="margin-left:30px; width:1000px;">
            <div class="row">
                <div class="col-xs-12">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                                <tr class="active">
                                    <th style="width:115px; padding-left:40px;">Data</th>
                                    <th style="width:180px; padding-left:60px;">Produto</th>
                                    <th style="width:115px; padding-left:18px;">Quantidade</th>
                                    <th style="width:125px; padding-left:15px;">Preço Unitário</th>
                                    <th style="width:135px; padding-left:10px;">Total do Produto</th>
                                    <th style="width:135px; padding-left:10px;">Total Compra</th>
                                    <?php
                                    $data = date("Y-m-d");
                                    $soma = 0;
                                    $dati = explode("-", $dato[$j]);
                                    $dataconvertida[$j]=$dati[2]."/".$dati[1]."/".$dati[0];
                                    $j=1;
                                    
                                    ?>
                                </tr>
                            </thead>
                            
                            <tbody>
                                <tr class="success">

                                    <td style="padding-left:15px;"><?php echo $dataconvertida[$i];?></td>
                                    <td style="padding-left:30px;"><?php echo $produtos[$cont][nome_produto]?></td></td>
                                    <td style="padding-left:30px;"><?php echo $quantidade[$i];?></td></td>
                                    <td style="padding-left:35px;"> R$<?php echo $produtos[$cont][valor_produto];?></td></td>
                                    <td style="padding-left:35px;"> R$<?php echo $produtos[$cont][valor_produto]*$quantidade[$i];?></td></td>
                                    <td style="padding-left:30px;"> R$ <?php $preço = (float)$preço; $total = (float)$total; $soma=(float)$soma; $total = $quantidade[$i]*$preço;  $soma = $soma + $total; echo $soma;?></td></td>
                                    <td><a href="excluirVenda.php?produto=<?php echo $codigoprodutoinserido[$i];?><?php echo $produto[$i];?>&cpf=<?php echo $cpfselecionado;?>&data=<?php echo $dato[$i];?>&quantidade=<?php echo $quantidade[$i];?>" class="btn btn-danger" role="button">Excluir Produto</a></td></td>
                                </tr>
                            </tbody>
                            
                        </table>
                    </div>
                </div>
            </div>
        </div>


#2 wanglii

wanglii

    Membro TOP

  • Membros
  • PipPipPipPip
  • 89 Posts:

Postou 09 novembro 2017 - 11:55

polo ralph lauren outlet

cheap jerseys

polo ralph lauren

ugg boots

uggs on sale

ugg boots

christian louboutin outlet

ralph lauren outlet

ugg boots outlet

ugg sale

nike air max

oakley sunglasses wholesale

pandora jewelry

uggs outlet

cheap ugg boots

coach outlet online

fitflops sale

longchamp bags

nfl jerseys

tory burch handbags

ugg outlet

coach outlet online

christian louboutin uk

lebron james shoes

oakley sunglasses wholesale

canada goose jackets

coach outlet

ralph lauren shirts

michael kors outlet store

pandora jewelry

uggs outlet

coach factory outlet

michael kors outlet clearance

christian louboutin outlet

canada goose jackets

ralph lauren shirts

kate spade purses

ugg outlet

michael kors outlet

canada goose

canada goose jackets

cheap ugg boots

valentino outlet store

true religion outlet

pandora rings

ugg outlet stores

michael kors outlet online

canada goose jackets

ray ban sunglasses on sale

coach factory outlet online

mcm backpack

michael kors outlet clearance

coach outlet store

coach outlet online

polo shirts

christian louboutin outlet

uggs on sale

canada goose jackets

cheap uggs

oakley sunglasses for men

canada goose outlet

coach factory outlet

air max 90

nike shoes

polo ralph lauren

ugg outlet online

pandora charms

cheap ugg boots

cheap mlb jerseys

polo outlet

pandora jewelry

coach outlet canada

ugg outlet

air max 90

canada goose outlet store

pandora jewelry

coach outlet

coach factory outlet

pandora jewelry

michael kors handbags

pandora outlet

coach factory outlet

fitflops sale clearance

michael kors outlet online

ugg outlet

michael kors outlet

cheap jordans

coach factory outlet

christian louboutin shoes

canada goose jackets sale

michael kors outlet store

20171110wanglili

#3 wanglii

wanglii

    Membro TOP

  • Membros
  • PipPipPipPip
  • 89 Posts:

Postou 10 novembro 2017 - 12:05

coach outlet store online

oakley sunglasses

coach outlet store online

michael kors outlet

polo ralph lauren

fred perry polo

tory burch outlet stores

ugg boots

canada goose outlet online

michael kors outlet

uggs canada

canada goose outlet

uggs outlet

cheap nba jersey

adidas nmd

fitflop sandals

mbt shoes

ugg outlet

pandora outlet online

polo ralph lauren outlet

lacoste outlet

ugg sale

adidas outlet

canada goose jackets sale

oakley sunglasses wholesale

ugg outlet

ugg outlet

pandora jewelry

adidas outlet

ralph lauren uk

canada goose uk

cheap ugg boots

canada goose jackets

mulberry outlet

canada goose jackets

coach outlet store online

nike shoes

coach factory outlet

ralph lauren uk

ugg outlet

christian louboutin shoes

canada goose outlet

nike outlet store

polo shirts

michael kors handbags

coach outlet

ray ban sunglasses

true religion outlet

canada goose outlet

ugg outlet

polo ralph lauren

fred perry polo

coach outlet online

ralph lauren polo

ugg outlet

michael kors handbags

canada goose outlet store

ugg outlet

mulberry outlet

michael kors outlet

mbt

uggs outlet

coach factory outlet

mont blanc pens

true religion outlet store

christian louboutin outlet

polo outlet

polo ralph lauren

coach outlet store online

fitflop sandals

moncler jackets

lacoste polo

canada goose parka sale

canada goose outlet

cheap ray ban sunglasses

ugg outlet online

nike outlet store

canada goose jackets

ralph lauren outlet

moncler sale

polo ralph lauren outlet

moncler outlet

pandora charms

cheap jordans

oakley sunglasses

yeezy boost 350

mbt shoes outlet

cheap mlb jerseys

ugg outlet

canada goose jackets

ralph lauren

michael kors outlet online

ugg boots

mont blanc

coach outlet store online

cheap ray bans

mont blanc pens

polo ralph lauren pas cher

michael kors outlet clearance

coach outlet

adidas yeezy shoes

ralph lauren sale clearance

longchamp handbags

canada goose jackets

canada goose outlet

mont blanc pens for sale

canada goose jackets

nike air jordan 4

michael kors handbags

michael kors outlet clearance

canada goose outlet online

michael kors outlet online

pandora bracelet

christian louboutin shoes

mlb jerseys wholesale

coach factory outlet

oakley sunglasses

oakley sunglasses wholesale

michael kors outlet

mont blanc pens

true religion

fitflops sale clearance

ugg outlet

true religion jeans

nike shoes for men

canada goose jackets

ray ban sunglasses

ralph lauren pas cher

cheap ugg boots

canada goose uk

oakley sunglasses wholesale

uggs outlet

cheap uggs

ugg boots australia

polo ralph lauren

canada goose jackets

coach factory outlet online

pandora charms

mlb jerseys

uggs on sale

ugg boots

uggs outlet

michael kors outlet clearance

ugg outlet

michael kors outlet

prada outlet

yeezy boost

canada goose outlet store

polo ralph lauren

michael kors outlet online

ugg outlet

oakley sunglasses

coach outlet

canada goose jackets

canada goose outlet

michael kors outlet online

michael kors outlet

polo ralph lauren

moncler outlet

valentino shoes

michael kors outlet online

ugg outlet

coach outlet online

canada goose outlet

christian louboutin

canada goose outlet stores

polo outlet

ralph lauren outlet

cheap ugg boots

ugg outlet store

canada goose outlet online

ugg outlet online

mulberry handbags

cheap ugg boots

ugg outlet

canada goose jackets

moncler jackets

mbt shoes clearance outlet

christian louboutin sale

michael kors outlet

michael kors handbags

canada goose outlet

mulberry bags

mont blanc outlet

mulberry handbags

asics running shoes

canada goose outlet store

jordan retro

yeezy boost 350 v2

kate spade outlet store

cheap oakley sunglasses

ugg outlet

canada goose uk

michael kors outlet

canada goose outlet

polo ralph lauren outlet

canada goose jackets

michael kors outlet clearance

coach outlet store online

lebron shoes

fitflops outlet

canada goose jackets

canada goose outlet

ugg boots

moncler outlet online

polo ralph lauren

ugg outlet store

20171110wanglili





Also tagged with one or more of these keywords: php, array, table

0 usuário(s) está(ão) lendo este tópico

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)