 <p>Try this,</p> <pre><code>session_start(); if(isset($_POST['viewrecord'])){ $sup_code = $_POST['vhidden']; } $_SESSION["sup_code"] = $sup_code; </code></pre> <p>SQL Query</p> <pre><code>$sql = "SELECT sup_code, firstname, lastname, email, telephone FROM dbo.table WHERE sup_code = '".$_SESSION["sup_code"]."'"; </code></pre>