using database in your forms


Only very simple forms can be done without a database: most likely you've already built a lot of database powered forms, where several fields (dropdowns, checkbox groups) need to be created using some database content.

Good news: using simple database wrappers Clonefish supports virtually any data source on Earth. Clonefish has several built-in database wrappers:

  • MySQL: to wrap the native mysql_* functions
  • PDO: PHP Data Objects is the built-in database abstraction layer since PHP 5.1
  • PEAR DB and MDB2 - the classic PEAR DB package for database abstraction and MDB2, its successor
  • AdoDB - another versatile database abstraction library

You can pass database connections to Clonefish and populate elements with values from SQL queries, like in this example:

<?php

$config = Array(
  Array(
    'type'        => 'selectDynamic',
    'displayname' => 'Choose country',
    'sql'         => 'SELECT id, name FROM countries ORDER BY name'
  )
);

?>

affiliate program!

Do you run a PHP blog or related website? Join as an affiliate and earn money!
know more

form validation for developers!

clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain forms
learn more
Bookmark and Share