简体   繁体   English

如果单击PHP的链接,则设置变量

[英]Set variable if link is clicked for PHP

I'm really novice to PHP so sorry in advance if the question is really stupid. 我真的不是PHP的新手,如果问题真的很愚蠢,请您提前抱歉。 But thank you for paying attention to the post and helping! 但是,感谢您关注此帖子并提供帮助!

事情实际上是什么样的

<?php
   if ($tableResult = mysqli_query($conn,"show tables")){
        while($table = mysqli_fetch_array($tableResult)) {
            echo("<th>". "<a class = 'list_tables'>". $table[0] . "</a>" ."</th>");
      }
   }else{
        die("<b>"."No Table in Database!"."</b>");
      }
?>

If I want to set a variable for the link clicked, and the variable contains a value of the shown name, how do I do that? 如果我想为单击的链接设置一个变量,并且该变量包含显示名称的值,我该怎么做?

If I'm wording it badly, please tell me, I will try to word it more clearly. 如果我的措词不当,请告诉我,我会尝试用更清晰的措词。

Thanks a lot for helping! 非常感谢您的帮助! It really means a lot to me 这对我很重要

Welcome :) 欢迎:)

If I'm reading this correctly, you want to pass which table was clicked to another page (or to the page you're on when it's reloaded). 如果我正确地阅读了此内容,则希望将单击哪个表的内容传递到另一个页面(或重新加载该页面时所在的页面)。 To do that, just set your href to something like this: 为此,只需将href设置为如下所示:

<a href='?clickedTable=$table[0]' class='list_tables'>". $table[0] . "</a>

Then on the php page, accept that variable like this: 然后在php页面上,接受如下所示的变量:

$table = $_GET["clickedTable"];

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

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