and manage data of MySQL databases. It also generates PHP code for creating the database itself as well.
Once you get used to PHPMagic (which takes no time), you'll be able to create amazingly powerful web database applications -- even if you know nothing about PHP, SQL, MySQL, html, ... etc. PHPMagic does it all for you, automatically.
PHPMagic 3 is the result of hundreds of user comments and feedback from people who used previous versions of PHPMagic. It is a whole new rebuild with many added features and a completely new and exciting look.
What will you find here?
•
A step-by-step guide to creating an online music database using PHPMagic.
•
A guide to using the generated pages and dealing with the database.
http://www.websitedatabases.com/ 2 In this section, I'll walk you through the simple steps needed to create your first
PHPMagic application. We'll consider a real-world database application as an example: A music albums collection.
I have lots of music CDs that are actually collections of various singers. And I find it really hard sometimes to find a song that I wish to listen to. So, let's begin to create an application to manage this task. It shall also have the
advantage of being an online application, which means you can put it on your web server and allow your friends to view it instead of asking you every time they want to borrow a CD if you have that song named bla bla bla.
We'll create a Singers table, a CDs table and a Songs table. You might wonder: Why don't I create one table for all the data?? Well ... dividing the data into several tables instead of one is called data normalization. Data normalization helps decrease the database size and retain data integrity. In brief, you create a table for each ‘object’ in your
system. So, songs are an object, singers another object and CDs a third object.
For more information about data normalization and other relational database design issues, I recommend you read the great tutorial by Selena Sol on databasejournal.com. (If you are not familiar with database design concepts, I highly recommend you check this tutorial before you continue reading this guide).
http://www.websitedatabases.com/ 3
• Singer name
• Country
• Comments
CDs table shall have these fields:
• CD number (automatically-incremented primary key)
• Creation date
• CD name (I like to give names to my CDs: Meditation, Night slows, Shadow, .. etc)
• Comments
And Songs table shall have these fields:
• Song Number (automatically-incremented primary key)
• Song name
• Singer (a foreign key field that accepts data only if it matches 'Singer number' field of the Singers table)
• CD (a foreign key field that accepts data only if it matches 'CD number' field of the CDs table)
http://www.websitedatabases.com/ 4 When you start PHPMagic, you see an empty working area.
Click on the 'New Project' icon to start a new project.
Please note:
This screenshot and all others are taken from PHPMagic version 1.0. Some icons you see have been changed in later versions of PHPMagic and the Trial version. However, you can create the entire example application shown here using the free trial version. Many new features have been added but the functionality is basically the same. This is simply a demo of how the application works.
http://www.websitedatabases.com/ 5
The project window is displayed. It has two panels.
The left panel is the Project Browser and contains a hierarchical view of your database. Now it has only one item: the database itself. The default name of the database is ‘new_db’.
The right panel is the Properties panel and it contains
information about the currently-highlighted item in the Project Browser.
http://www.websitedatabases.com/ 6 Click twice (but not double-click) on the item 'new_db', or press F2, to change the database name. We’ll change it to 'music'.
http://www.websitedatabases.com/ 7 After typing the new name, click anywhere in the window to
http://www.websitedatabases.com/ 8 We then define the connection parameters for the database. Simply type the server name or IP, the username and the password in the Properties panel.
If you don't know these values, contact your server administrator.
http://www.websitedatabases.com/ 9 Next, we create the tables of the database. Click on the 'New Table' icon.
http://www.websitedatabases.com/ 10 Now 'table1' is created. To change its name highlight the table in the Project Browser and press F2 or click on it.
http://www.websitedatabases.com/ 11 We rename it to 'singers'.
http://www.websitedatabases.com/ 12 We'll create another table, 'cds' in the same manner.
http://www.websitedatabases.com/ 13 We’ll rename the table to ‘cds’.
http://www.websitedatabases.com/ 14 as shown before.
http://www.websitedatabases.com/ 15 We'll adjust some properties for each table now. The Caption property is the title of the table that users of your application will see.
Users won’t see the actual name of the table since it has many restrictions (lower case letters, no spaces, no special characters, .. etc). But the caption can be almost anything you want (except single quotation marks).
http://www.websitedatabases.com/ 16 We have just changed the caption of the 'singers' table to
http://www.websitedatabases.com/ 17 And the caption of the 'cds' table to 'CDs Table', and 'songs' table to 'Songs Table'.
http://www.websitedatabases.com/ 18 We'll now create some fields. We select the 'singers' table and then click on the 'New Field' icon to create a new field in the selected table.
Voila! 'field1' is created. We'll change the new field name by selecting it and pressing F2.
http://www.websitedatabases.com/ 19 We changed the name to 'singer number'.
http://www.websitedatabases.com/ 20 We'll now edit some properties of the selected field in the
http://www.websitedatabases.com/ 21 The field caption is changed to 'Singer Number'. A field caption is what your application users will see in their browser instead of the field name.
http://www.websitedatabases.com/ 22 We checked 'Primary key' so that the selected field becomes the primary key of the table.
A primary key is a field used to uniquely identify each record in the table. For example, if we say “the record whose primary key field is equal to 125587”, then we are talking about one and only one record in the table.
The singer number is going to be the primary key field of the singers table in our example.
http://www.websitedatabases.com/ 23 Auto Increment means the field will contain an automatic counter that increases whenever a new data record is added to the
database.
http://www.websitedatabases.com/ 24 Let's create some more fields ...
And we rename it to “singer_name” in the same way we renamed tables before.
http://www.websitedatabases.com/ 25 Singer name will be a text field of type 'VarChar' and length 40.
http://www.websitedatabases.com/ 26 Then we create another field, ‘country’, and set its properties ...
If you have PHPMagic Professional, you can define several countries to choose from in the Value list box. This will let your users choose the country from a drop down menu instead of typing it.
http://www.websitedatabases.com/ 27 Here are all the fields created. 'singer' and 'cd' fields of the
'songs' table shall be foreign keys to link the 'songs' table to the 'singers' and 'cds' tables. Let's set this now ...
http://www.websitedatabases.com/ 28 We set the Parent table to 'singers', Parent ID field to the primary key field of the 'singers' table which is 'singer_number', and
Parent caption field to 'singer_name' so that the users see the singer names instead of their serial numbers.
Please note that the data type of the foreign key field must match that of its parent id field.
http://www.websitedatabases.com/ 29 We do the same with 'cd' field.
http://www.websitedatabases.com/ 30 That's all! Your project is ready for generation of the PHP
application. Click on the 'Generate PHP code' icon, or press F5.
You're asked now to select an output folder where the application files will be created. It's recommended you select an empty folder or create a new folder in order not to mix any files. After selecting the output folder, PHPMagic generates the application files and displays a detailed log. Click 'Close' to close the window.
http://www.websitedatabases.com/ 31 Click the 'Exit' icon to quit PHPMagic.
The next step is to upload the application to your web server and set it up. (http://yourdomain.com/your_phpmagic_folder/setup.php)
http://www.websitedatabases.com/ 32 PHP application. It contains links to all the tables we created in our PHPMagic project.
TIP!
If you wish to change the look of this page, you can look for the file
‘index.html’ in the generated files folder and open it in your favorite HTML editor and perform your magic!
http://www.websitedatabases.com/ 34 before trying to view its tables. However, PHPMagic reminds us of doing so and provides a link to the setup page.
http://www.websitedatabases.com/ 35 We'll click on the link to set up the database.
http://www.websitedatabases.com/ 36 Here we are! The database is created
http://www.websitedatabases.com/ 39 Here we can view data records, add new records, edit and delete existing records, sort and filter records.
But since this table is new, it is still empty. We shall now add a new data record.
http://www.websitedatabases.com/ 40 Note that the 'Country' field has a menu of allowable data values. This was done in PHPMagic Professional Edition by defining a values list for this field.
http://www.websitedatabases.com/ 41 We now click the 'Add New Record' button to save data to the table.
http://www.websitedatabases.com/ 42 Observe the new buttons that appear in the Detail View.
Notice also that Singer Number was
automatically set to '1' since we defined this field as 'Auto Increment' in PHPMagic.
http://www.websitedatabases.com/ 44 'Micheal Jakson' and edit his data.
http://www.websitedatabases.com/ 45 the Detail View.
http://www.websitedatabases.com/ 46 We add a comment and then save changes by clicking the 'Update Record' button.
http://www.websitedatabases.com/ 49 We'll delete 'Britney' from the table by clicking the 'Delete Record' button.
http://www.websitedatabases.com/ 52 The 'Print' button displays the table without the buttons and the detail view so that users can print it. We'll click this button now.
http://www.websitedatabases.com/ 53 return to the previous view.
http://www.websitedatabases.com/ 54 The 'Edit Filters' button displays a filters page so that we can search the data in the table according to criteria we'll define.
http://www.websitedatabases.com/ 55 'Or' to indicate how the filter is combined with other filters. Filters consist of a field
name, a comparison operator and a comparison value ...
http://www.websitedatabases.com/ 57 To apply your filter(s), click the 'Apply Filters' button.
http://www.websitedatabases.com/ 59 The 'Clear Filters' button removes all filters.
http://www.websitedatabases.com/ 61 PHPMagic allows us to sort data by any field. Simply click on the field header.
http://www.websitedatabases.com/ 65 The 'Select A Table' menu allows you to view any other table by selecting it.
By now we have reached the end of our
Getting Started guide. Try PHPMagic on your own now and see for yourself the possibilites and powers. Context help is availble
everywhere in PHPMagic by clicking F1 anytime. Enjoy!
http://www.websitedatabases.com/ 66 databases having tens and even hundreds of tables. You can do it without a single line of code. No need to spend hundreds of hours writing SQL, PHP or HTML code. No need to hire expensive programmers to do it for you either. And even if you need to customize the generated files, you know you won’t have to start from scratch. You know that you have already saved yourself tons of programming time and effort. The generated code is very neat and easy to understand. Many customers told us that they used it to learn PHP!
Now, think of it: Isn’t saving yourself hundreds of hours in programming, thousands of dollars in programmers’ costs, endless testing and debugging efforts … isn’t saving all of these worth a little investment in PHPMagic?