문제


I would like to know how I can use the GET-method in my .php file: forumdocument.php to get the ID of the href that is clicked in table.php
I hope this is the right way to begin it:

'<a class="formtitellink" href="forumdocument.php" id="$row['ID']">' . $row['Titel'] . '</a>' . "</td>";

table.php:

$query = "Select *
        from forum";
$resultaat = mysql_query($query, $connectie);
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Tijd</th>
<th>Gebruikersnaam</th>
<th>Titel</th>
</tr>";

while($row = mysql_fetch_array($resultaat))
  {
  $_SESSION['row'] = $row;
  echo "<tr>";
  echo "<td>" . $row['Tijd'] . "</td>";
  echo "<td>" . $row['Gebruikersnaam'] . "</td>";
  echo "<td>" . '<a class="formtitellink" href="forumdocument.php" id="$row['ID']">' . $row['Titel'] . '</a>' . "</td>";
  echo "</tr>";
  }
echo "</table>";
도움이 되었습니까?

해결책

A GET method is used for name value pairs in a url.

Example: www.test.com?var1=var1&var2=var2

Here if we use $_GET['var1'] the expected value would be var1.

Just change your links to reflect the desired variable

href="forumdocument.php?rowid=".$row['ID']."

Then you can use retrieve the id using something like this on forumdocument.php

$rowid = $_GET['rowid'];

다른 팁

Change this part

a class="formtitellink" href="forumdocument.php" id="$row['ID']"    

a class="formtitellink" href="forumdocument.php"?id="'.$row['ID'].'"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top