PHP dynamic form elements

In a previous we explained how to use PHP to create a dynamic SELECT menu. The same way it’s possible to use PHP to create other form elements.

Create a radio group with PHP

Creating radio elements in some content management systems can result into writing a lot of code. Just in case your radio group with multiple options is getting a value from a database and/or a form. There need to be a check for every posted value for every option. This function will do all this work for you, just create two arrays, one for the values and labels and for the related html code. It’s up to the user if he uses 2 or more elements in one group. The function works with $_POST and $_GET data.

Continue reading PHP dynamic form elements

Create a dynamic select menu with PHP

In many HTML forms or content management systems the form element “SELECT” is used frequently. If you use your PHP code inside the standard HTML element the code will be nearly unreadable. Adding extra options is not really fun. This small handy function will produce a select menu based on an associative array. Just define an array and call the function, that’s all you need to do. Continue reading Create a dynamic select menu with PHP

Create a select menu from files or directory

This simple function generates a select element for all files of a given directory. Use this function together with the PHP download script on this site. The function is modified to work with “register_globals = off “. Use this custom function in forms to update dynamic image names in a database table. We demonstrate the select menu on our upload page demo, just upload a new file and select the uploaded file from the select menu on the demo page. Continue reading Create a select menu from files or directory