Taking the OOP Plunge
<p>I decided to start or try to start coding in OOP for my PHP apps.  here is my first class.  the intention of this class is to start a form and build the different elements.  please let me know if it is even in the right track.  The fields are already stored in the database. the priority param is not doing anything yet, but will highlight the question.</p>

<pre><code>//Form Class
&lt;?php

class form {

        function genQuestion ($id) {

        $type = $this-&gt;getQuestionType($id);

        $priority = $this-&gt;getQuestionPriority($id);

        if ($field['type'] == "text") {
            $html .= $this-&gt;add_text_field($id, $priority);
        }
        if ($field['type'] == "select") {
            $html .= $this-&gt;add_select_field($id, $priority);
        }
        if ($this-&gt;type == 'radio') {
            $html .= $this-&gt;add_radio_field($id, $priority);
        }
        if ($field['type'] == "checkbox") {
            $html .= $this-&gt;add_checkbox_field($id, $priority);
        }       

        return $html;

    }

    function getQuestionType ($id) {
        $field_query = "SELECT type FROM fields WHERE id = '$id'";
        $field = mysql_query($field_query);
        $field = mysql_fetch_assoc($field);
        $this-&gt;type = $field['type'];       
    }   

    function getQuestionPriority ($id) {
        $field_query = "SELECT priority FROM fields WHERE id = '$id'";
        $field = mysql_query($field_query);
        $field = mysql_fetch_assoc($field);
        $this-&gt;type = $field['priority'];       
    }       

    function add_text_field($id) {
        $fields_query = "SELECT * FROM fields WHERE id = '$id'";
        $fields = mysql_query($fields_query);
        $field = mysql_fetch_assoc($fields); 
        $content .= '&lt;div&gt;&lt;label&gt; ' . $field['field'] . ': &lt;/label&gt;';       
        $content .= '&lt;input type="text" name="' . $field['id'] . '"&gt;&lt;/div&gt;';
        return $content;
    } 

    function add_select_field($id) {
        $fields_query = "SELECT * FROM fields WHERE id = '$id'";
        $fields = mysql_query($fields_query);
        $field = mysql_fetch_assoc($fields); 
        $content .= '&lt;div&gt;&lt;label&gt; ' . $field['field'] . ': &lt;/label&gt;';       
        $options = explode('|', $field['options']);
        $content .= '&lt;select name="' . $field['id'] . '"&gt;'; 
        while (list($key, $value) = each($labels)) {
            $content .= '&lt;option value="' . $key . '"&gt; ' .  $value . '&lt;/option&gt;';
        }
        $content .= '&lt;/select&gt;&lt;/div&gt;';
        return $content;
    } 

    function add_radio_field($id) {
        $fields_query = "SELECT * FROM fields WHERE id = '$id'";
        $fields = mysql_query($fields_query);
        $field = mysql_fetch_assoc($fields); 
        $content .= '&lt;div style="float: left; margin: 0 auto; width: 500px; text-align: right; clear: both;"&gt;&lt;div style="float: left; width: 200px; margin-right: 25px;"&gt;&lt;label&gt; ' . $field['field'] . ': &lt;/label&gt;&lt;/div&gt;';      
        $options = explode('|', $field['options']);
        while (list($key, $value) = each($options)) {
            $content .= '&lt;div style="float: left; margin-right: 7px;"&gt;' . $value . '&lt;/div&gt;&lt;div style="float: left;  margin-right: 17px;"&gt;&lt;input type="radio" name="' . $field['id'] . '" value="' . $key . '" /&gt;&lt;/div&gt;';
        }
        $content .= '&lt;/div&gt;';
        return $content;
    } 

    function add_checkbox_field($id) {
        $fields_query = "SELECT * FROM fields WHERE id = '$id'";
        $fields = mysql_query($fields_query);
        $field = mysql_fetch_assoc($fields); 
        $content .= '&lt;div&gt;&lt;label&gt; ' . $field['field'] . ': &lt;/label&gt;';       
        $content .= '&lt;input type="checkbox" name="' . $field['id'] . '" value="' . $field['options'] . '" /&gt; ' . $field['labels'] . '&lt;/div&gt;';
        return $content;
    }       

}

?&gt;


//Controller
$fields_quesry = "SELECT * FROM fields";
$fields = mysql_query($fields_quesry);

$form = new form;

$form-&gt;genQuestion($field['id']);
</code></pre>
