My problem is that I need to save a value from the link as a variable which will then do something. Below is my main code for this problem.
<table>
<? foreach ($csv as $row) : ?>
<tr>
<td><a href="?GoToProfile"><? echo $row[0]; ?></a></td>
</tr>
<? endforeach; ?>
</table>
Basically, it prints the first column from my array $csv. However I want to save the '$row[0]' for each link - depending on which one is clicked.
This happens here:
<?php
if (isset($_GET['GoToProfile'])) {
}
?>
This works. E.g. when something is clicked it prints something. But I cannot find a way to save the values from each link. Depending on which one is clicked. I have tried many different methods online, but none seem to work.
I have even tried:
<a href="?GoToProfile?id=<?php $row[0]; ?>"><? echo $row[0]; ?></a>
Any help would be greatly appreciated. Thanks!
答案 0 :(得分:1)
使用&符号(&amp; )代替问号
<a href="?GoToProfile&id=<?php $row[0]; ?>"><? echo $row[0]; ?></a>
?表示查询字符串的开头,即 GET 请求发送的数据。在大多数情况下,它是一组名称/值对,用&amp; 分隔。
GET请求的简单示例
您可以使用$ _GET
获取PHP中参数的值$first = $_GET['first'];
$second = $_GET['second'];
要查看服务器正在接收的内容,您可以使用 var_dump
var_dump($_GET)