-1

This php file finds every ".html" file and ".txt" file and creates a dynamically table with a link to another page. In that page i want to show in a frame the html file clicked on.

 <html>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <body>

        <?php

        echo '<h2>Escolha o Esquema de MetaDados a utilizar</h2>';
        echo '<table cellspacing="0" cellpadding="0" border="0" class="table">';
        echo '<tr>';
        echo '<th>Esquema de MetaDados</th>';
        echo '<th>Descrição</th>';
        echo '</tr>';

              foreach (glob("Templates/Dinamico/*.html") as $filename) {
              foreach(glob("Templates/Dinamico/*.txt") as $txtname){ 
               $fileH= basename($filename,".html");
               $fileT= basename($txtname,".txt");   
              if($fileH==$fileT){ 
              $txt= file_get_contents ( $txtname); 
            if($filename != "Templates/Dinamico/formD1.html"){ 
                echo'<tr>';
                echo'<td>';
                echo "<a name='".$fileH."'strong href='Templates/Dinamico/formD1.php'>".$fileH."</a>";
                echo'</td>';
                echo'<td>';
                echo $txt;
                echo'</td>';
                echo'</tr>';               
    }
    }
    }
    }
        ?>
    </body>

    </html>

This file is where the link page set above and it the a element clicked on populate the iframe with the name assign to the "a" element.

  <html>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <body>
        <div>

        <?php

This $a var i want to be the $fileH clicked on

              echo '<iframe src="' .$a.'" frameBorder="0" width="70%" height="100%" align="left" scrolling="no" />';
              echo '</iframe>'
        ?>
    </div>

    </body>

    </html>
Luis Luis Maia Maia
  • 681
  • 1
  • 10
  • 30

1 Answers1

1

you can add an id as a property to that url like this:

echo "<a name='".$fileH."'strong href='Templates/Dinamico/formD1.php?id=$fileH'>".$fileH."</a>";

and then in your other page simply get the id with $_GET['id']; that's it. Find here more reference on how to pass variables. link1,link 2 or link 3