Jump to content

PHP form class


mahalleday

Recommended Posts

Does anyone have or know of an easy to use php form generation class that can accept data pulled from mysql database tables?  I have started to build my own but I because my oo php skills are somewhat limited I know there has to be some one out there who has already done this are far better than anything I have written.  Why re-invent the wheel right.

 

Here is the method I wrote to pull an associative array from a database and create a select list.

//create select box from database
    function formSelectBoxDB($inputs, $sql, $val, $key) {
$query = mysql_query($sql);
$select  = '<select';
$select .= ' name="'.$inputs['name'];
$select .= '" id="'.$inputs['id'];
$select .= '" class="'.$inputs['class'].'">';
$select .= '<option value="">Select '.$inputs['id'].'</option>';
while($rows = mysql_fetch_array($query, MYSQL_ASSOC)) {
    $select .= '<option';
    $select .= ' value="'.$rows[$key].'">';
    $select .= $rows[$val];
    $select .= '</option>';
    $i++;
}
$select .= '</select>';

return $select;
    }

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/203387-php-form-class/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.