Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

BMCouto
2007 year 6 month 27 day Wednesday 16:01:14 MDT 

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <script type="text/javascript" src="jquery.js"></script>
  6.                 <script type="text/javascript">
  7.                                                 jQuery.noConflict();
  8.                                                 function apagaPedido( id_pedido ) {
  9.                                 $.ajax({
  10.                                         type: "GET",
  11.                                         url: "pedido.php?action=elimina&id_mesa=<?=$_GET['id_mesa'];?>&id_pedido=" + id_pedido,
  12.                                         success: function(msg){
  13.                                                                                                 alert( 'msg: ' + msg );
  14.                                                                                                  $("#pedidos").html(msg);
  15.                                         }
  16.                                 });
  17.                         }
  18.                 </script>
  19. </head>
  20. <body>
  21.  
  22. <?
  23. //require "classes.php";
  24.  
  25. require "ligaBD.php";
  26.  
  27. $id_mesa = $_GET['id_mesa'];
  28.  
  29. if(isset($_GET['action']) && $_GET['action'] == "adiciona") {
  30.  
  31. $id_pedido = "mesa".$_GET['id_mesa']."pedido".time();
  32. $id_produto = $_GET['id_produto'];
  33.        
  34.         $query = "INSERT INTO pedidos (id_pedido, id_mesa, id_produto) VALUES ('$id_pedido', '$id_mesa', '$id_produto')";
  35.        
  36.         mysql_query($query) or die(mysql_error());
  37.        
  38. }
  39.  
  40. if(isset($_GET['action']) && $_GET['action'] == "elimina") {
  41.        
  42.         $query = "DELETE FROM pedidos WHERE id_pedido='".$_GET['id_pedido']."'";
  43.        
  44.         mysql_query($query) or die(mysql_error());
  45.        
  46. }
  47.  
  48. /*$selectProduto = mysql_query("SELECT id_produto FROM pedidos WHERE id_mesa=1");
  49. if(mysql_num_rows($selectProduto) == 0) {
  50.     echo 'Esse produto n�o existe na base de dados.'; die();
  51. }
  52. $produto = mysql_fetch_object($selectProduto);
  53. $mostraDados = mysql_query(sprintf("SELECT nome, preco FROM ementa WHERE id_produto=%s", $produto->id_produto));
  54. while($pedido = mysql_fetch_array($mostraDados)){
  55.  
  56. for($i=0;$i<count($pedido);$i++) {
  57.        
  58.         echo "<div id='pedidos'>";
  59.         echo "<div id='nomePedido'>".htmlentities($pedido[0])."</div>";
  60.         echo "<div id='precoPedido'>".$pedido[1]."&euro;</div>";
  61.         echo "<div id='eliminaPedido'><a href='#'><img src='imagens/icons/elimina.png'></a></div>";
  62.         echo "</div>";
  63.        
  64. }
  65. }*/
  66. $Ssql = "SELECT ementa.nome,ementa.preco,pedidos.id_pedido FROM ementa, pedidos WHERE pedidos.id_mesa='$id_mesa' AND pedidos.id_produto = ementa.id_produto";
  67. $Rsql = mysql_query($Ssql) or die("Erro ao contactar a BD!". mysql_error());
  68. while($pedido = mysql_fetch_array($Rsql)){
  69.         echo "<div id='pedidos'>";
  70.         echo "<div id='nomePedido'>".htmlentities($pedido[0])."</div>";
  71.         echo "<div id='precoPedido'>".$pedido[1]."&euro;</div>";
  72.         echo "<div id='eliminaPedido'><a href='#' id='elimina' name='elimina' onClick='apagaPedido(".$pedido[2].")'><img src='imagens/icons/elimina.png'></a></div>";
  73.         //echo $pedido[2];
  74.         echo "</div>";
  75. }
  76.  
  77. //$selectIDPedido = "SELECT id_pedido FROM pedidos WHERE id_mesa='$id_mesa' AND id_pedido='$pedido[2]' ";
  78.  
  79. //DIVS COM TOTAL, FINALIZAR
  80.  
  81. ?>
  82.  
  83. </body>
  84. </html>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation