TransWikia.com

Putting some calculations on a database entry from phpmyadmin

Database Administrators Asked by farhangdon on December 12, 2021

I am creating an online store website for sale/purchase. I have to put a specific percentage of an amount (User enters) in database.

for example
If user enters 100. I have to deduct 30% of it and I want to put 70 in database. Is there a way I can perform this check from phpmyadmin ?. I know I can do it from code but can I do it from phpmyadmin ?

Thanks for help.

One Answer

You could do this in phpMyAdmin, but you shouldn't.

If you insist, you could use an input transformation to do so. You'd have to write one, but doing so shouldn't be too difficult if you have a basic knowledge of PHP. However, this is a bad idea for many reasons, the biggest of which is that you shouldn't be giving your users access through phpMyAdmin. phpMyAdmin is meant as a tool for a system administrator to manage their databases and by giving your users direct access, they in turn can do whatever they want, including changing the percentage to work in their benefit or modifying costs, quantities, or order details that they shouldn't have access to. Plus the interface is not what you want to present to a user, anyway. You should write your own custom application code (or use some application designed for sales and purchase) rather than forcing your users to interact with your database through phpMyAdmin.

I know you said you don't want to do it through code, but the two ways to handle this properly are through your application code or through code on the MySQL side (either through a stored procedure or a trigger on that column).

Answered by ibennetch on December 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP