Php Extracting items from a list

0

How do I stop extracting items from a <table> using php??

The situation is as follows:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"url_onde_pego_os_dados");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);

In case $ result is a <table> with the items I want to extract.

example

<tr class="primeiroregistro">
             <td align="left">ABC</td>
             <td align="left">Atol ABC  </td>
             <td align="left">Plastico</td>
             <td align="right">13,45</td>
             <td align="right">13,01</td>
             <td align="right">13,65</td>
             <td align="right">13,27</td>
             <td align="right">13,28</td>
             <td align="right">-1,26%</td>
             <td align="right">13,25</td>
             <td align="right">13,28</td>
             <td align="right">1.368</td>
             <td align="right">506.500</td>
           </tr>
    
asked by anonymous 22.09.2018 / 19:43

1 answer

0

Add the following code in your table so you have a source code to pick up your current line (where it's clicked).

<td>
   <button type="button"
           onclick="pegarEssaLinha(this)">
      Pegue esta Linha
   </button>
</td>

Now in Javascript put this function, because it will be triggered by the click of the button there in the table.

function pegarEssaLinha(elemento) {
    // Linha atual
    var linhaAtual = $(elemento).closest("tr");
    // Celulas
    var coluna0 = linhaAtual.find("td:eq(0)").text().trim();

    window.alert(colunaID);
}

Note that the snippet where you have > > > td: eq (0)

22.09.2018 / 21:11