简体   繁体   English

HTML表行中的PHP $ _GET

[英]PHP $_GET from HTML table row

so I have a table of data that gets produced in PHP. 所以我有一个用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. 我希望的是,有一个按钮可以查看该表行中的特定数据,即按“视图图”,它使用$ _GET方法获取该行的值的ID,然后使用它显示数据。 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? 我如何获取每行的ID /名称以解析到新页面?

You can create with the url/argument: 您可以使用url /参数创建:

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>");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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