Upload data from a query to a lightbox

0

I'm developing a system, and I have the following code that returns the results of a query:

 $Dados = $conn->getResult();

foreach ($Dados as $Linha):

  echo $Linha['event_name'];
  echo   "<a href='teste.php?id_event={$Linha['id_event']}'>Mais Informações</a><br />";

endforeach;

That results in this:

Nowcomesmyquestion:HowcouldIopenalightboxonthissamepagewithouthavingtoreloadit,pickingupalltheinformationofacertainquerywhenIclickonthe"More information"?

for example:

(Of course where this show_name would be the name of the show that I clicked on for more information, and so with all the other information of the result)

Much obliged right now!

    
asked by anonymous 15.09.2016 / 23:52

1 answer

1

You will need to use ajax with the creation of interactive forms for the query

for example

In the column where you generate the name, you also generate the id, or other identifier attribute within the parameter of the onclick function, for example

<a onclick="maisDetalhes($Linha['id_event'])">Mais Informações</a><br />

get this the id by the parameter in the javascript function

funtion(id){
var formulario = document.CreateElement("form"); //cria um elemento form
formulario.id = "form1";
formulario.action "paginadosDados.php";
formulario.method = "POST"; //ou get seilá

var input1 = document.CreateElement("input");
input1.type = text;
input1.name = "input1";
input1.value = id; //parâmentro que vc acabou de enviar 

formulario.appendChild(input1);

document.body.appendChild(formulario);

var data = $("#form1").serialize(); //pega o valor do form e envia sem recarregar

$.ajax({
        type : 'POST',
        url  : 'paginadosDados.php', // substitua
        data : data,
        dataType: 'json',
        beforeSend: function()
        {    
aqui vai a animação do carregando...
  } 
  success :  function(response){                        
            if(response.codigo == "0"){ 
           alert(response.mensagem);
  }
  }
  });
}

php only returns what you want and sends the results to that part of the success

example

$retorno = array('codigo' => 0, 'mensagem' => 'oi');
echo json_encode($retorno);
exit();

obs: link the J-query to get easier, this code I wrote here in the editor so it has not been tested yet

    
16.09.2016 / 03:08