Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
nao estou conseguindo fazer ofinalizar.php
esse é o teste.php
depois ele manda para o carrinho.php
<?php session_start();
$flag=0;
for($i=0; $i<sizeof($_SESSION[carrinho]);$i++)
{
if($_SESSION[carrinho][$i]==$_GET[id])
{
$flag=1;
}
}
if($flag==0)
{
array_push($_SESSION[carrinho],$_GET[id]);
//array_push=> armazena um valor no vetor
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtmll//DTD/xhtmll-strict.dtd"/>
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="content-type" content="text/html"; charset="ISO-8859-1"/>
<title>Mercado online</title>
<link rel="stylesheet" href="estilo.css" type="text/css" title="tema padrao"/>
</head>
<body>
<?php
//include "cabecalho.php.inc";
include "conexao.php.inc";
$escolha=$_POST[escolha];
$marca=$_POST[txtnome];
if($escolha=="auto falante")
{
$nome=$_POST[escolha];
$comando="select * from produto where categoria='$nome' and marca like'%$marca%'";
}else if($escolha=="amp")
{
$nome=$_POST[escolha];
$comando="select * from produto where categoria='$nome' and marca like'%$marca%'";
}else if($escolha=="cornetas")
{
$nome=$_POST[escolha];
$comando="select * from produto where categoria='$nome' and marca like'%$marca%'";
}else if($escolha=="sub")
{
$nome=$_POST[escolha];
$comando="select * from produto where categoria='$nome' and marca like'%$marca%'";
}else if($escolha=="twit")
{
$nome=$_POST[escolha];
$comando="select * from produto where categoria='$nome' and marca like'%$marca%'";
}
else
{
$nome=$_POST[escolha];
$comando="select * from produto where categoria='$nome' and marca like'%$marca%'";
}
$res=mysql_query($comando,$conexao);
?>
<div class="produtos">
<h1>Escolha os produtos q deseja clicando em"adicionar ao carrinho de compras"</h1>
<table border=0 width="100%" cellpading="100">
<?php
while($produto=mysql_fetch_row($res))
{
echo"<tr>
<td>$produto[2]</td><td>R$ $produto[5]</td><td><img src='../fotos/$produto[6]'/></td>
<td align=left><a href={$_SERVER['PHP SELF']}?id=$produto[0]><img src='../fotos/carrinho.gif'/></a></td></tr>";
}
$fecha=mysql_close($conexao);//fechou a conexao com bd
?>
</table>
</div>
<br>
<div class="rodape">
<form name="carrinho" method="post" action="carrinho.php"><!--formulario para finalizar a compra-->
<input type="submit" value="verificar carrinho"/><br></form>
</div>
</body>
</html>
/////////////////////////
agora vem o carrinho.php
<?php session_start();
$cod=$_SESSION['testes'];
if($_GET[x] == 1)//se foi acionado o link para remover um item do carrinho
{ //recebo o codigo do produto, colocando-o em um vetor
$y=array($_GET[id]);
//retira o elemento do carrinho
$_SESSION[carrinho]=array_diff($_SESSION[carrinho],$y);
//ordena o vetor
sort($_SESSION[carrinho]);
}
$_GET[x]=0;
?>
<!DOCTYPE html PUBLIC "-//w3c//dtd xhtml 1.0 strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<html xmlns="[http://www.w3(.org/1999/xhtml">](http://www.w3(.org/1999/xhtml)
<head>
<meta http-equiv="content-type" content="text/html"; charset="ISO-8859-1"/>
<title>Mercadinho On-line</title>
<link rel="stylesheet" href="estilo.css" type="text/css" title="tema default"/>
<script type="text/javascript">
function calcular()
{
totalparcial=0;
totalgeral=0;
for(i=0; i<document.dados.quantidade.length; i++)
//percorrendo todas caixas de texto
{
totalparcial=parseFloat(document.dados.quantidade[i].value) * parseFloat(document.dados.preco[i].value);
document.dados.totalparcial[i].value=totalparcial;
totalgeral+=totalparcial;
}
document.dados.totalgeral.value = totalgeral;
}
</script>
</head>
<body>
<?php
//include"cabecalho.php.inc";
include"conexao.php.inc";
?>
<div class="produtos">
<h1>Lista de compras:</h1>
<form name="dados">
<table width="800">
<tr>
<td>Produtos</td><td>Quantidade</td><td></td><td>Preço Unitário</td><td>Total</td>
</tr>
<?php
$i=1;
do
{ //passa cada posição do vetor para $x
$x = $_SESSION[carrinho][$i];
//seleciona todos registros cujo código esteja no carrinho
$consultasql="select * from produto where cod_produto='$x'";
$res=mysql_query($consultasql,$conexao);
$produto=mysql_fetch_row($res);
?>
<tr>
<td><?php echo $produto[2]; ?> </td><td> <input type="text" value="1" name="quantidade" size="3" maxlength="3"/></td><td>
<?php echo"<a href={$_SERVER['PHP_SELF']}?id=$produto[0]&x=1>Retirar produto</a>$cod";?></td>
<td><input type="text" name="preco" value="<?php echo $produto[5]?>" size="3" /></td>
<td><input type="text" name="totalparcial" value="<?php echo $produto[5]?>" size=3 /></td>
</tr>
<?php
$_SESSION[quan]=$_POST[quantidade];
$i++;
} while($i < sizeof($_SESSION[carrinho]));
$fecha=mysql_close($conexao);//fechou a conexao com o banco
?>
<tr>
<td colspan=4 align="right"><b>Total Geral: </b></td><td><input type="text" name="totalgeral" value="" size="4"/></td>
</tr>
</table>
<input type="button" value="recalcular" onclick="calcular()" />
</form>
</div>
<div class="rodape">
<form name="fim" method="post" action="finalizar.php">
<input type="submit" value="Finalizar a compra"/><br/>
</form>
<br/>
<a href=
</div>
</body>
</html>
meu projeto de escola
nao to conseguindo fazer o finalizar.php
nao consigo mandar a quantidade pra mim da baixa pq ele ta com o name=quantidade para todos no while
me ajudem galera.....
tenhu que entregar meu projeto na segunda se nao pifffo eu reprovo....
valeww
Carregando comentários...