pre-populate a web form based with PHP Variables that are based on user selection
<p>I have a web form that is generated from a $_GET function.</p>

<p>I would like to populate some input fields in this web form from the data that was passed using PHP.</p>

<p>Any ideas how I could go about doing this?</p>

<p>Thanks</p>

<h2>Here is the PHP (which is successfully passed the variables from the row that the user selected, phew!)</h2>

<pre><code>&lt;html&gt;
&lt;?php
    require_once 'config.php';
    $dbh = new PDO($dsn, $dbuser, $dbpass);
    $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbh-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    $id = $_GET['id'];
    $sth = $dbh-&gt;prepare('
        SELECT a_aif.aif_id,
          a_aif.fee_source_id,
          a_aif.company_name_per_sedar,
          a_aif.document_filing_date
        FROM  a_aif
        WHERE a_aif.fee_source_id = :id');
    $sth-&gt;bindParam(':id', $id, PDO::PARAM_STR);
    $sth-&gt;execute();
    $result = $sth-&gt;fetch(PDO::FETCH_ASSOC);
?&gt;

&lt;form action="submit_data.php" method="get" autocomplete="on"&gt;

&lt;?php
    echo implode ( ', ', $result);
    echo "&lt;br&gt;";
?&gt;
</code></pre>

<p><strong>Here is where I would like to include the company name</strong></p>

<pre><code>Company Name:&lt;input type="text" name="coname" value="&lt;?php $result[a_aif.company_name_per_sedar];?&gt;"&gt;&lt;br&gt;
</code></pre>

<p>and the rest of the form...</p>

<pre><code>Year-End:&lt;input type="date" name="year-end"&gt;&lt;br&gt;
Auditor:&lt;input list="auditor" name="auditor"&gt;&lt;br&gt;
</code></pre>
