How To Create A PHP Front-End To Your MySQL Database Using DaDaBIK
Sure, all PHP developers have used PHPMyAdmin, but have you heard of DaDaBIK? In this article Eugenio talks about DaDaBIK and shows us how to use it to create a front-end for a MySQL database with it in under 5 minutes.
How To Create A PHP Front-End To Your MySQL Database Using DaDaBIK - Database Table Creation (contd.) (Page 3 of 5 )
You should see a screen that looks something like this:
Here's an example of searching for a customer whose last name is Smith:
... and the corresponding result:
We can update this result by clicking on the edit icon (the first of the three icons before the record in the table):
Of course we can also insert and delete records just by following the menus. So, I hear you say, is that all that DaDaBIK can do? Well, no... what you've seen is only the beginning. The strength of DaDaBIK lies in the possibility to customize the interface we have just created and now we are going to see how to do it.
Customization The first thing to notice is that we don't want the same fields in all of the DaDaBIK forms; for example in the insert form we don't need the ID_cust field because it is an auto incrementing field. We also don't want the update_date_cust field, because DaDaBIK has to fill this field in automatically when a record is updated. In the search form, instead, we want to give the possibility to perform a research by using the first name, last name or job type fields, so we want to include only the first_name_cust, last_name_cust and job_cust fields.
Another important feature of DaDaBIK is the ability to change the way that table fields are displayed -– we can give them "friendlier" display names.
Almost all of the customisation options for DaDaBIK are available through the admin.php script, so point your browser to http://localhost/my_dadabik/admin.php:
Click on the "Internal table manager". The internal table manger is a tool that allows us to modify the interfaces we use for our MySQL tables (in this case the interface of customers_tab); from the internal table manager you can choose the label of the fields that you want to display in the forms, which fields are required, the content type of the fields and so on. Click on the "Show all fields in a page" button to have all of the fields displayed in a page and start configuring your interface:
In this example I changed the label of ID_cust from ID_cust to ID customer, and I also decided not to include this field in the insert/update forms, as well as the search form:
I will also change the label of the field first_name_cust to First name, which looks better and is easier to understand:
I change the field type property of update_date_cust, setting it to update_date. Update_date is a built-in DaDaBIK field type (we'll see more about these later in the article). By using this type, DaDaBIK doesn't show the field in the insert/update form, but will automatically fill it with the current date when the content of a record is modified.
We then change labels and the "Field present" properties for all of the fields according to our needs and then we save the configuration.