title: Javascript and PHP (window.open)
body: <p>So, in my website, I have a news system which has an option to edit and delete the news the administrator desires.</p>
  
  <p>Well, I got the edit part right by using:</p>
  
  <p><code>href="noticiaEditarForm.php?id_noticia=&lt;?php echo $id ?&gt;"&gt;Editar&lt;/a&gt;</code></p>
  
  <p>And then a <code>$_GET</code> on the other page.</p>
  
  <p>However, this is not how I desire my editing window. 
  Therefore, I have been exploring a way to send the PHP variable that contains the primary key for the news table (MySQL) to a popup window, using JavaScript. But that's just the thing, it will only return the 1st value it gets from the query... (i.e If I click to edit the 3rd article, it edits my 1st one. Always.)</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>&lt;div class="noticias"&gt;
  &lt;?php
      include('conn/conn.php');
      mysql_select_db($bd, $conn);
  
      $resultado = mysql_query("SELECT * FROM noticia INNER JOIN user ON noticia.id_user=user.id_user ORDER BY id_noticia DESC");
  
      while ($linha = mysql_fetch_array($resultado)) {
          echo "&lt;h1&gt;" . $linha['titulo'] . "&lt;/h1&gt;";
          echo "&lt;i&gt;Posted by " .$linha['username']. " on " . "&lt;y&gt;" . $linha['data'] . "&lt;/y&gt;" . "&lt;/i&gt;";
          echo "&lt;p&gt;";
          echo $linha['texto'];
  
          $id = $linha['id_noticia'];
  
          if (isset($_SESSION['admin'])) {
  ?&gt;
              &lt;div class="noticiasOpcao"&gt;
                  &lt;a href="" onClick="open_win_editar()"&gt;Editar&lt;/a&gt;
                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  &lt;a onclick="return confirm('Are you sure?')" href="noticiaApagar.php?id_noticia=&lt;?php echo $id ?&gt;"&gt;Apagar&lt;/a&gt;
              &lt;/div&gt;
  &lt;?php
          } 
      }
  ?&gt;
  
  &lt;script language="javascript"&gt;
      function open_win_editar() {
          window.open (
              "noticiaEditarForm.php?id_noticia=&lt;?php echo $id; ?&gt;",
              "Editar notícia",
              "location=1, status=1, scrollbars=1, width=800, height=455"
          );
      }
  &lt;/script&gt;
  
  &lt;?php mysql_close($conn); ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>My point is to then use another query to get the title and text of the article to display on an WYSIWYG editor.</p>
  
  <p>Can anyone point out my flaw?</p>