Ronald Ng Ronald Ng - 1 year ago 72
PHP Question

Set variable if link is clicked for PHP

I'm really novice to PHP so sorry in advance if the question is really stupid. But thank you for paying attention to the post and helping!

How the thing actually looks like

if ($tableResult = mysqli_query($conn,"show tables")){
while($table = mysqli_fetch_array($tableResult)) {
echo("<th>". "<a class = 'list_tables'>". $table[0] . "</a>" ."</th>");
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

Answer Source

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:

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

Then on the php page, accept that variable like this:

$table = $_GET["clickedTable"];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download