Minimize jQuery Function
<p>I have a function that adds change events for form items based on the row name(uses the database to get these).</p>

<p>Heres the current function:</p>

<pre><code>    $sql = "SELECT * FROM product WHERE storeno = '1' ORDER BY descript";
    $result = mssql_query($sql, $msConnection);

    if ($result &amp;&amp; mssql_num_rows($result) &gt; 0) {
        while ($row = mssql_fetch_object($result)) {
            $sku = trim($row-&gt;mas90sku);
            $JQueryReadyScripts .= "
            $('#newCount_" . $sku . "_row .cases').change(function() {
                var count = 0;
                $('#newCount_" . $sku . "_row .cases').each(function () {
                    count += parseFloat($(this).val());
                });
                $('#cases_total_" . $sku . "').text(count);
            });
            $('#newCount_" . $sku . "_row .units').change(function() {
                var count = 0;
                $('#newCount_" . $sku . "_row .units').each(function () {
                    count += parseFloat($(this).val());
                });
                $('#units_total_" . $sku . "').text(count);
            });";
        }
        mssql_free_result($result);
    }
</code></pre>

<p>How can I consolidate this into a call that affects every row so that I can get rid of the DB portion and have just 2 pieces (or 1) of code instead of 2 for every row.</p>
