Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>sorry for making you guys lost your time. I finally resolved my issue:</p> <p>In my Javascript (using JQuery) i've done:</p> <pre><code>$(document).ready(function() { // relativo ao main.html $("#over_tabela tr").mouseover( function() { $(this).addClass("sobre_linha"); }).mouseout( function() { $(this).removeClass("sobre_linha"); }); // this is to "delete" the row from the table of main.html file throw ajax and JSON $('a.delete_link').click(function(e){ e.preventDefault(); if(confirm('Tem a certeza?')){ url = $(this).attr('href'); $.ajax({ type: "GET", url: url, dataType: "json", success: function(msg){ $('#linha_'+ msg.id).hide("slow"); } }); } }); </code></pre> <p>}); </p> <p>Then in my apagar.html :</p> <pre><code>&lt;%args&gt; $rid =&gt; '' &lt;/%args&gt; &lt;%once&gt; use lib '/var/www/projectox/'; use db::Conexao; # module that interact with database use DBI; use Apache2::Cookie; #cookies, not the right way, gonna update to Session Cookies &lt;/%once&gt; &lt;%init&gt; # vê se existem cookies my $cookies = Apache2::Cookie-&gt;fetch($r); if(!$cookies) { #sem cookies é enviado para o login $m-&gt;redirect('login.html'); } if($rid) { # vai eliminar os dados pelo valor do id ($rid) #database connection my $tomada = db::Conexao-&gt;Conexao(); my $sql = $tomada-&gt;prepare("Delete from Contactos where id=?") || die "Impossivel de realizar a operação: $!"; $sql-&gt;execute($rid) || die "Não foi possivel executar: $!"; # execute or die with a message #disconnect from database or warn about problem $tomada-&gt;disconnect || warn "Não foi possivel terminar a ligação!"; print qq{ { id : $rid } }; #JSON style, this was what made me go crazy... lol and in the end was soooooo easy as that } &lt;/%init&gt; </code></pre> <p>and finally in my main.html:</p> <pre><code> &lt;%args&gt; $sair =&gt; 0 &lt;/%args&gt; &lt;%once&gt; use lib '/var/www/projectox/'; use db::Conexao; use DBI; use Apache2::Cookie; &lt;/%once&gt; &lt;%init&gt; # vê se existem cookies my $cookies = Apache2::Cookie-&gt;fetch($r); if(!$cookies){ #without cookies user is redirect to login.html $m-&gt;redirect('login.html'); } if($sair){ # if he logout : cookie expire and user is sent to index.html my $cookie = Apache2::Cookie-&gt;new($r, -name =&gt; "CHOCO", -value =&gt; "TWIX", -expires=&gt; '+0s' ); $cookie-&gt;bake($r); $m-&gt;redirect('../index.html'); } my $tomada = db::Conexao-&gt;Conexao(); my $sql = $tomada-&gt;prepare("Select * from Contactos") || # select all from table Contactos or die.. die "Impossivel : $!"; $sql-&gt;execute() || die "Nao foi possivel executar: $!"; # Generate HTML here print qq{ &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="pt" xml:lang="pt"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html"; charset="utf-8" /&gt; &lt;link rel="stylesheet" type="text/css" href="../shadowbox/shadowbox.css"&gt; &lt;link rel="stylesheet" href="../css/estilo.css" type="text/css" /&gt; &lt;script language="javascript" src="../js/jquery.js"&gt;&lt;/script&gt; &lt;script language="javascript" src="../js/wii.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../shadowbox/shadowbox.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; Shadowbox.init({ language: "pt-PT", players: ["html","iframe","qt"], viewportPadding: 30, overlayOpacity: 0.9, overlayColor: "#9999ff" }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="logout" name="logout" action="" method="post" &gt; &lt;p&gt; &lt;input type="submit" id="sair" name="sair" value="Sair" /&gt; &lt;/p&gt; &lt;/form&gt; Bem Vindo #USERNAME ! &lt;table id="over_tabela" name="over_tabela" align="center" border="0" cellspacing="1" cellpadding="5"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;NOME&lt;/th&gt;&lt;th&gt;E-MAIL&lt;/th&gt;&lt;th&gt;MENSAGEM&lt;/th&gt;&lt;th&gt;OP&amp;Ccedil;&amp;Atilde;O&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; }; my @dados; # receive data from database my $dados; # part of @dados, id -&gt; $dados[0]; nome -&gt; $dados[1] etc.. while ( @dados = $sql-&gt;fetchrow_array() ) { #data is sent in html table form print qq{ &lt;tbody&gt; &lt;tr id="linha_$dados[0]"&gt; &lt;td&gt;$dados[1]&lt;/td&gt;&lt;td&gt;$dados[2]&lt;/td&gt;&lt;td&gt;$dados[3]&lt;/td&gt; &lt;td&gt; &lt;a class="edit_link" href="/back/editar.html?rid=$dados[0]" rel="shadowbox;width=440;height=320"&gt; &lt;img src="../imagens/editar.png" width="24" height="24" border="0" title="Editar" /&gt; &lt;/a&gt; &amp;nbsp; &lt;a class="delete_link" href="/back/apagar.html?rid=$dados[0]"&gt; &lt;img src="../imagens/eliminar.png" width="24" height="24" border="0" title="Apagar" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; }; } print qq {&lt;/table&gt; &lt;/body&gt; &lt;/html&gt;}; #end of HTML #disconnect from database $tomada-&gt;disconnect || warn "Não foi possivel terminar a ligação: $!"; &lt;/%init&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload