TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Form Function (http://www.talkphp.com/general/1730-form-function.html)

TlcAndres 12-13-2007 09:01 PM

Form Function
 
Just wanted some thoughts on the the efficiency of this function

PHP Code:

    function FormGenerate($frmname,$to,$values=array(),$echo=false,$len='30',$submitto='',$special=array())
        {
            
//set up the form and create the action
                        
$submit = !empty($submitto) ? "onSubmit='".$submitto."'" '';
            
$data '<form name="'.$frmname.'" method="post" action="'.$this->siteinfo['url'] . $to.'" '.$submit.'>
                        <table>'
;
            
                     
                        
$tag reset(array_keys($special));
                        
$rep reset($special);
            
//start the loop, this method is supposed to be more efficient
            
while(list(, $v) = each($values))
            { 

                
$type = ($v == $tag) ? $rep 'text';
                
//create the table and such
                
$data .= '
                    <tr>
                <td><label for="'
.$v.'">'.$v.'</label><td>
                            <td><input name="'
.$v.'" id="'.$v.'" value="" size="'.$len.'" maxlength="255" type="'.$type.'"></td>
                    </tr>'
;
                               
$tag sizeof(array_keys($special)) > next(array_keys($special)) : $tag;
                               
$rep sizeof($special) > next($special) : $rep;                                    
            }
            
            
//finish it all off
            
$data .= '<tr><td><input value="submit" type="submit"></td></tr></table>'
            
            
//return it all
            
if($echo) { echo($data); }else{ return $data; }
        } 



All times are GMT. The time now is 04:35 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0