Please use the code snippet feature to post code examples here at EE. It gives us a unispace font and line numbers that facilitate discussion. Here is the code from the original question, shown in the code snippet.

That said, is this a real application with economic value? If so, please consider getting professional help with the project. There are a number of red flags here that lead me to believe you may be building a brittle piece of software. Examples:

SELECT *
This causes a complete table scan, transferring all fields in all matched rows. It's usually the first culprit when performance suffers. A better strategy would be to SELECT the columns you need by name.

no LIMIT, GROUP or ORDER clauses
Again, performance related, but also this indicates that the data may not be well organized. A professional DBA could give you a moment's advice that would be hugely valuable.

SUBSTRING in a WHERE clause
Make a Google search for the exact phrase, Should I Normalize My Database, and read the very interesting positions on either side of the argument. With very tiny tables, it may not matter. If your tables grow to any size at all, you want to be able to write queries that do their work quickly. SUBSTRING makes me think that your tables may not have the appropriate indexes.

PHP substr() in retrieved rows
Another data organization problem. It appears that the data base may fail the ACID test. A better strategy would be to organize the tables' columns into elements that can be addressed in the query, rather than after the data (perhaps too much data) has been transferred.

Use of MySQLI_Fetch_Array() function
By default this function returns twice as much data as you need, so it is guaranteed to create a performance penalty. Fortunately you can find all of the PHP functions documented in the online man pages, so by simply reading the function descriptions you can avoid mistakes like this one.

Use of switch/case without default
This virtually guarantees that a data error can cause the script to behave in an unpredictable manner.

Use of program code to determine data values
This should really be part of a data base lookup. As written, you will find that you have to change the programming when a rate change occurs. And that means that you must rerun all of your unit and integration tests for even a penny-change in the rates. That is what we call a design flaw; a better design would abstract the list of numbers and the rate table so that maintenance, additions and deletions of numbers and rates could be done without any programming changes.

Introduction
Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).
The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …

The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…