FAQ

I already have a MySQL database. How can I use it with PHPMagic?
You have two ways of doing this: The hard way, and the easy way!

The hard way involves redefining all the tables and fields of your database in PHPMagic, making sure that field data types and sizes are correctly set, primary keys correctly defined, unique fields correctly set, … etc.

The above is so tedious obviously, specially when you have large databases. So, we come to the easy way: MySQL2PHPMagic. This is a tiny add-on wizard that does all the work on your behalf. You get this software Free when your purchase phpmagic pro or our phpmagic plus version.

Both methods above will result in an PHPMagic project file that can be used to generate a web interface for your database.

Is there a way to make a table that is editable by admin user, and only viewable by other people?

Generate two copies of your application. One for users and the other for admins, each in a separate folder. That’s a very common approach for web developers. They write two versions of their database applications: one for users and one for admins.

Upload the admin version of the generated files to a password-protected folder and give the password only to authorized persons. If you want to protect the users version of your application, use a different login and password for its folder. We also offer a php/mysql script generator to create members area access to any area on your site. more…

I don’t want users to be able to delete records, but I do want them to be able to add. Is this possible?

Within PHPMagic you can enable or disable each table’s functionality by simply checking or unchecking the tic-boxes for allowing adding, deleting, updating, hiding and more. For example you, the admin may want all the admin features enables so you would check all the checkbox and save the project file in foldera. Create a second project file and enable only the add checkbox. Save this project file in folderb. Now generate your project files for each project file. Upload both folders with the generated code to your web server. Run the setup.php file from either foldera or folderb. This only needs to be done once. Once the setup.php file has been ran you should delete the setup.php file from both folders. The setup.php file creates a file named config.php. Depending on the folder you ran the setup.php from copy the created config.php to the other folder. Now you would use the link www.yourdomain.tld/folderb/index.html from your html doc or web page for end users. To login as admin only you would know the path to the foldera or admin files so you can have a path like www.yourdomain.tld/foldera/secretfolder/index.html

Can PHPMagic display images?

Sure! First of all, you need to know that the images aren’t really stored in the database. Instead, only the path to the images is stored in the database, while the images are saved on your server’s hard drive in a folder.

For this reason, the database field you use as an image field must be a text-type field. PHPMagic forces this field to be a CHAR or VARCHAR of length 40 or more. If you check “Display as image in table view”, PHPMagic scripts would read the image path stored in the image field and display the image in the table view. “Display as image in detail view” is the same as above except that the image is displayed in the detail view. If you check both options, the image will appear in both the detail and table views. Checking the option “Allow users to upload images” will display a “Browse” button for users so that they can choose an image from their computer to upload.

But what happens when users upload an image or file? First of all, PHPMagic scripts check to see if the uploaded file is indeed a file type you selected for this field and it’s size doesn’t exceed the size you specify in the box labeled “Maximum acceptable image size in bytes”.

One final thing you should know about handling images: Where does PHPMagic store the uploaded images? Images are stored in a subfolder named “images” inside the folder where you have uploaded the scripts.

If you want to change this to another location, open the generated file “language.php” and change the path in the last line of code in this file, which reads: $Translation[“ImageFolder”] = “./images/”; Change ./images/ above to the appropriate path. Remember to move in images in the old path to the new one.

Is it possible to have a dropdown that combines 2 fields? Let’s say I have a table that has 3 fields: id, fname, lname. I want the user to select a fname, lname combo so the id gets stored in a second table.
Yes. Let’s assume your table is called “clients”. One of the generated files will be named “clients_dml.php”. Open it in a text editor, and find the function called form(). Look for a line that reads something like this:

$combo_name->Query = “select id, lname from authors order by lname”;

This is the query used to populate the drop down menu. Change it to:

$combo_name->Query = “select id, concat(fname, ‘ ‘, lname) from authors order by lname”;

This will “concatenate” or join first name and last name in the drop down.

I want to allow users specific access permissions.
Take a look at our Plus version which allows you the admin to control access of users using group access permissions.

How can I calculate a formula based on two or more fields, for example, subtotal=unit_price * quantity?
Let’s assume your table is called “order_data”. In the folder containing the PHPMagic-generated files, look for a file named “order_data_view.php”. Open this file in a text editor.

Now, on line 17 of that file, you will see the SQL query used to display the table view. It looks something like this (on a single line):

$x->Query = “select item as ‘Item’, unit_price as ‘Unit price’, qty as ‘Quantity’ from order_data”;

All you need to do is modify the query to something like this (on a single line):

$x->Query = “select item as ‘Item’, unit_price as ‘Unit price’, qty as ‘Quantity’, unit_price * qty as ‘Subtotal’ from order_data”;

Then save the changes and upload the file to your web server.

How do I make “TimeStamp” field viewed like “mm/dd/yyyy” or “mm-dd-yyyy” in table view?
You’ll need to make some tiny code modifications for changing date format. To change the date format in table view, open the generated file “tablename_view.php” in your text editor, go to line 17, which reads something like:

$x->Query = “select …., timestamp_field as ‘Time Stamp’, … from …..”;

Now change it to:

$x->Query = “select …., DATE_FORMAT(timestamp_field,’%d/%m/%Y %H:%i:%s’) as ‘Time Stamp’, … from …..”;

This would display the date as day/month/year hour:minute:second … you can modify the format string ‘%d/%m/%Y %H:%i:%s’ to change the way the date is displayed.

Why does my virus program warn me every time I try to use PHPMagic to generate code?
PHPMagic uses a Windows component called Scripting Host (scrrun.dll). It uses it to copy files during code generation. Since many email viruses use the same component to do malicious operations (deleting files or altering them … etc), virus scanners issue an alert when any application tries to use this component.

You should choose to continue or put PHPMagic in the allowed list as it merely uses the scripting host to copy its generated files.

Please note that you should regularly scan your system for viruses to ensure all files are virus-free.

 

How can I add clickable links in the table?

It can be done using a simple tweak. Use a VarChar or a Char field in which you will store the URL of your link. Let’s call this field ‘my_link’ and let’s assume that the table name is ‘products’.

After PHPMagic generates the PHP code, find the file named ‘products_view.php’ and open it in a text editor … go to around line 17, which contains the query used to display the table data:

SELECT blablabla, products.my_link as ‘Link’, blablabla FROM products …

Now, modify the query to read:

SELECT blablabla, CONCAT(‘‘, products.my_link, ‘‘) as ‘Image’, blablabla FROM products …

How can I change appearance or theme of my database?

The appearance of the generated application can be customized through CSS styles using the styles button within PHPMagic. You can easily create your own customized style. We have a few samples here to get you started. You can also use the generated blank header.php and footer.php files to give your database more appealing and effective by simply inserting you own html code.

How about different language support ?

We have had some users submit language.php files to replace the engish language file generated.