简体   繁体   中英

PHP $_GET from HTML table row

so I have a table of data that gets produced in PHP. What I was hoping for, would be to have a button to view that specific piece of data in that table row, ie press 'view graph' and it uses the $_GET method to take the id of the value of that row, and use it to display data. This instead of creating an individual page for each graph, so it just produces the relevant data for that page.

At the moment, my code looks like this:

if ($id==$server_id){
    echo("<tr><td>".$row2['hostname']."</td>
    <td><a href=".$url.">".$row['name']."</a></td>
    <td><span class='label label-$alerting'>"
    .$row['capacity'].
    "%</span></td>
    <td><input type='submit' value='View Graph'></td>
    </form></tr>");
}

How would I get the id/name for each row to parse into a new page?

You can create with the url/argument:

if ($id==$server_id){
    echo("<tr><td>".$row2['hostname']."</td>
    <td><a href=".$url.">".$row['name']."</a></td>
    <td><span class='label label-$alerting'>"
    .$row['capacity'].
    "%</span></td>
    <td><a href='yourUrl?id=".$row['id']."'>View Graph</a></td>
    </tr>");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM