Pass back values to form to populate it? (lots of values)
<p>I need to pass back a large string of results to a form, so that the form can read those results from the URL and then populate the form with them. Problem is, the link ends up being:</p>

<p>&amp;key=value&amp;key=value ... until it can't process anymore (I assume a URL has a length limit?) resulting in my form not being able to fully populate. I need another way to pass values back to my form file.</p>

<p>VIEW.php file (basically just a table of values right as they are from the database, with the first column "id" being a link. When I click on "id", it goes back to my add.php(form page) and populates the form with the data matching that id)</p>

<pre><code>&lt;table border="0" cellpadding="0" cellspacing="0" id="table"&gt;
            &lt;thead&gt;
                &lt;tr&gt;
                    &lt;th&gt;ID&lt;/th&gt;
                    &lt;th&gt;NAME&lt;/th&gt;
                    &lt;th&gt;MANUFACTURER&lt;/th&gt;
                    &lt;th&gt;MODEL&lt;/th&gt;
                    &lt;th&gt;DESCRIPTION&lt;/th&gt;
                    &lt;th&gt;ON HAND&lt;/th&gt;
                    &lt;th&gt;REORDER&lt;/th&gt;
                    &lt;th&gt;COST&lt;/th&gt;
                    &lt;th&gt;PRICE&lt;/th&gt;
                    &lt;th&gt;SALE&lt;/th&gt;
                    &lt;th&gt;DISCOUNT&lt;/th&gt;
                    &lt;th&gt;DELETED&lt;/th&gt;
                    &lt;th&gt;&lt;/th&gt;
                &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody&gt;
                &lt;?php } ?&gt;
                    &lt;?php 
                        // loop to fetch data
                        while($row = mysql_fetch_array($result)) {
                        echo "&lt;tr&gt;";
                        echo "&lt;td&gt;
                        &lt;a href='molszewski1_a2_add.php'&gt;$row[id]&lt;/a&gt;&lt;/td&gt;";
                        echo "&lt;td&gt;$row[name]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[manufac]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[model]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[descrip]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[onhand]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[reorder]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[cost]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[price]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[sale]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[discont]&lt;/td&gt;";
                        echo "&lt;td&gt;$row[deleted]&lt;/td&gt;";

                        $status = "$row[deleted]";

                        echo "&lt;td&gt;&lt;a href='molszewski1_a2_delete.php?id=$row[id]&amp;flag=$status&amp;sort=$sort'&gt;";

                        $status = "$row[deleted]";

                        if ($status == 'n') {
                            $flag = "restore";
                            echo "delete";
                        } else if ( $status == 'y') {
                            $flag = "delete";
                            echo "restore";
                        }

                        echo "&lt;/a&gt;&lt;/td&gt;";
                        echo "&lt;/tr&gt;";
                    } ?&gt;
                &lt;?php { ?&gt;
            &lt;/tbody&gt;
        &lt;/table&gt;
</code></pre>

<p>ADD.php (form page where the form is supposed to fetch the data and populate it)</p>

<pre><code>&lt;?php
    // If no form has been submitted, present form
    if (empty($_GET))
    {   
        add_form();
    }
    // if a form has been submitted
    else
    {       
        // if form_validity() == 1, proceed to connect
        if (form_validity() == 1)
        {
            // connect to mysql + database
            connect();

            $saleItem = "n";
            $discountItem = "n";

            if( array_key_exists( 'saleItem', $_GET ) &amp;&amp; $_GET['saleItem'] == 'y' )
            { $saleItem = "y"; }
            if( array_key_exists( 'discountItem', $_GET ) &amp;&amp; $_GET['discountItem'] == 'y' )
            { $discountItem = "y"; }

            // get values from form, insert into database
            $sql=("INSERT INTO inventory (name, 
                                          manufac, 
                                          model, 
                                          descrip, 
                                          onhand, 
                                          reorder, 
                                          cost,  
                                          price, 
                                          sale, 
                                          discont,
                                          deleted)
                   VALUES ('$_GET[itemName]', 
                           '$_GET[manufacturer]', 
                           '$_GET[model]', 
                           '$_GET[description]', 
                           '$_GET[numberOnHand]', 
                           '$_GET[reorderLevel]', 
                           '$_GET[cost]',
                           '$_GET[sellingPrice]', 
                           '$saleItem', 
                           '$discountItem', 'n')");

            // if the query doesn't work, display error message
            if (!(mysql_query($sql))) { die ("could not query: " . mysql_error()); }

            add_form(); 

            // redirect to view.php after form submission
            // use php instead
            echo "&lt;meta http-equiv='REFRESH' content='0;url=molszewski1_a2_view.php'&gt;";
        }
        else
        {
            // if form is not valid (form_validity returns 0), display error messages
            add_form();
        }
    }
    ?&gt;
</code></pre>

<p>FUNCTIONS.php (all my functions for stuff like the form)</p>

<pre><code>&lt;?php function page_navigation(){ ?&gt;
&lt;div class="center"&gt;
&lt;a href="molszewski1_a2_add.php" id="add"&gt;&lt;input type="button" value="ADD" /&gt;&lt;/a&gt;
&lt;a href="molszewski1_a2_view.php?sort=all&amp;title=VIEW ALL" id="view"&gt;&lt;input type="button" value="VIEW" /&gt;&lt;/a&gt;
&lt;a href="?sort=deleted&amp;title=VIEW DELETED" id="add"&gt;&lt;input type="button" value="VIEW DELETED" /&gt;&lt;/a&gt;
&lt;a href="?sort=active&amp;title=VIEW ACTIVE" id="view"&gt;&lt;input type="button" value="VIEW ACTIVE" /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;?php } ?&gt;
&lt;?php function add_form() { ?&gt;
&lt;form action="molszewski1_a2_add.php" method="get" id="form"&gt;
    &lt;table width="529px"&gt;
        &lt;tr&gt;
            &lt;td&gt;ITEM NAME&lt;/td&gt;
            &lt;td&gt;&lt;input name="itemName" size="30" type="text" value="&lt;?php echo $_GET["itemName"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;MANUFACTURER&lt;/td&gt;
            &lt;td&gt;&lt;input name="manufacturer" size="30" type="text" value="&lt;?php echo $_GET["manufacturer"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;MODEL&lt;/td&gt;
            &lt;td&gt;&lt;input name="model" size="30" type="text" value="&lt;?php echo $_GET["model"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;DESCRIPTION&lt;/td&gt;
            &lt;td&gt;&lt;textarea name="description" rows="3" cols="20"&gt;&lt;?php echo $_GET["description"] ?&gt;&lt;/textarea&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;ON HAND&lt;/td&gt;
            &lt;td&gt;&lt;input name="numberOnHand" size="30" type="text" value="&lt;?php echo $_GET["numberOnHand"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;REORDER LEVEL&lt;/td&gt;
            &lt;td&gt;&lt;input name="reorderLevel" size="30" type="text" value="&lt;?php echo $_GET["reorderLevel"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;COST&lt;/td&gt;
            &lt;td&gt;&lt;input name="cost" size="30" type="text" value="&lt;?php echo $_GET["cost"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;SELLING PRICE&lt;/td&gt;
            &lt;td&gt;&lt;input name="sellingPrice" size="30" type="text" value="&lt;?php echo $_GET["sellingPrice"] ?&gt;"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;SALE ITEM&lt;/td&gt;
            &lt;td&gt;
                &lt;input type="checkbox" name="saleItem" value="y" &lt;?php if( isset( $_GET['saleItem'] ) ){ ?&gt; checked="checked" &lt;?php } ?&gt; /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;DISCOUNTED ITEM&lt;/td&gt;
            &lt;td&gt;
                &lt;input type="checkbox" name="discountItem" value="y" &lt;?php if( isset( $_GET['discountItem'] ) ){ ?&gt; checked="checked" &lt;?php } ?&gt; /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td colspan="2"&gt;&lt;input type="submit" value="save" name="submit" id="submit" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/form&gt;
&lt;?php } ?&gt;
</code></pre>
