Link in computer table that submits a field to a plug

Asked

Viewed 46 times

0

Good morning, you guys, I have a table, which is a query select of the data of the devices I control. In it I have several elements, such as Name, Macaddress and IP, for example. In the IP column, I wish for a link and from it (the IP of my device) I do another query filtering the data only from that device.

Follows my code:

echo '<table>';
    echo '<tr>';
        echo '<td width="270"><center><b>NOME DO DISPOSITIVO</b></td>';
        echo '<td width="130"><center><b>IP</b></td>';
        echo '<td width="230"><center><b>MAC ADDRESS</b></td>';
        echo '<td width="130"><center><b>GATEWAY</b></td>';
        echo '<td width="130"><center><b>REDE</b></td>';
        echo '<td width="230"><center><b>MÁSCARA DA REDE</b></td>';
    echo '</tr>';
echo '</table>';

while($aux = mysqli_fetch_assoc($sql)) {  
    echo '<table id="tborpo"><tbody><tr id="tbcorpo">';
    echo '<td id="nome" width="270">'.$aux["NAME"].'</td>';
    **echo '<td width="130"><a href="fichas/ficha.php">'.$aux["IPADDR"].'</a></td>';**
    echo '<td width="230"><center>'.$aux["MACADDR"].'</td>';
    echo '<td width="130">'.$aux["IPGATEWAY"].'</td>';
    echo '<td width="130"><center>'.$aux["IPSUBNET"].'</center></td>';
    echo '<td width="230"><center>'.$aux["IPMASK"].'</center></td>';
    echo '</tr></tbody></table>';
}

`

  • I don’t understand one thing. You want this IP field to be a link for you to click and be redirected to a page with the data of this link?

  • Perfectly. I don’t know how to make this link "submit" (I don’t know if Submit is the best method) for a php function that Filters the fields.

  • You want to do it dynamically on the same page where you are or you want to be redirected even to another one, like a href?

  • I wish I was a true href.

1 answer

0

To create a link in a structure like this, just put the tag <a> and insert a dynamic href whose value reflects the record you are displaying:

echo '<table>';
    echo '<tr>';
        echo '<td width="270"><center><b>NOME DO DISPOSITIVO</b></td>';
        echo '<td width="130"><center><b>IP</b></td>';
        echo '<td width="230"><center><b>MAC ADDRESS</b></td>';
        echo '<td width="130"><center><b>GATEWAY</b></td>';
        echo '<td width="130"><center><b>REDE</b></td>';
        echo '<td width="230"><center><b>MÁSCARA DA REDE</b></td>';
    echo '</tr>';
echo '</table>';

while($aux = mysqli_fetch_assoc($sql)) {

    echo '<table id="tborpo"><tbody><tr id="tbcorpo">';
        echo '<td id="nome" width="270">'.$aux["NAME"].'</td>';
        echo '<td width="130"><a href="fichas/ficha.php"><a href="/URL/DA/PÁGINA/DE/INFORMAÇÕES/DO/COMPUTADOR/?ipAddr='.$aux["IPADDR"].'">'.$aux["IPADDR"].'</a></td>';
        echo '<td width="230"><center>'.$aux["MACADDR"].'</td>';
        echo '<td width="130">'.$aux["IPGATEWAY"].'</td>';
        echo '<td width="130"><center>'.$aux["IPSUBNET"].'</center></td>';
        echo '<td width="230"><center>'.$aux["IPMASK"].'</center></td>';
    echo '</tr></tbody></table>';

}
  • Filipizaum, I have about 1000 devices. I can’t create 1000 pages. So I thought of a query

  • It makes a single page to display information from any computer. On this page you query the computer based on a Unique field.

  • I got it! I used the "GET" method and applied a query on top of the variable ipAddr ! Thanks to all who contributed!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.