how do i fix my php application making browser unresponsive

good day, i have an application which i have developed in php and MySQL but when i populate the database with lots of data(data required by the application) it makes the browser unresponsive and takes longer to execute, can anyone please help me resolve this. I include the code below.

[php]<?php
include_once ‘dbConfig.php’;
$query=“SELECT * FROM medications”;
$result= $con->query($query);
?>

Select Disease
<?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>
<?php echo $row['diagnosis'];?>
<?php } ?>

               <?php  
                 $query="SELECT * FROM medications";
                 $result= $con->query($query);
                ?>  
                      <select id="nol" style="width: 30%; ;" name="prescription" required="true" data-toggle="tooltip" data-original-title="medications" class="date-picker form-control col-md-7 col-xs-12" data-rel="chosen">
                        <option value="">Select Medicatioon</option>
                         <?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>
                        <option value="<?php echo $row['prescription']?>"><?php echo $row['prescription'];?> </option> 
                  <?php } ?> 
                     </select>

[/php]

I know it is a Coding application, but I don’t know what you are trying to do… Based on what I see, it is entirely wrong. If you had a system with every ICD10 code, you are talking tens of thousands of rows being returned. Dumping everything into the table is definitely not how that should be handled, much less twice.

ok im trying to do a billing system in which a user selects a disease and its medication from drop downs populated from a database

if my approach is wrong, which better way can i use?

It has been a LONG while since I was doing ICD-9/ ICD-10 codes, but that is A LOT of data to comb thru.

Autocomplete is likely your best option, whether that be on the code, the description, or another value. Something else would be, to select a category in one field that triggers the loading of another field of diagnoses, that triggers another field of sub-options.

You should also ONLY select the columns from the database that is needed, not everything.

actually i am using autocomplete to search for the disease and medication,and even if i change the query to select only the diagnosis and not everything it still makes the browser unreponsive which i thnk its because of the amount of data that it loops through, and when i add limit to the query it works just fine

That is exactly the issue. I am working on a similar problem now, that the system loops 32.7 billion times. The system is bogged and just dies.

:frowning: okay… can you tell when you have resolved it

My issue is with over used loops. Your issue is the initial design, which is part of my issue as well.

I don’t see autocomplete, or a limiter on your queries. That is why I was saying to have 3 selectors, each would narrow the selection more with a limited amount of data needed. Do you have wireframes that you are going off of for the design?

here is the code which have autocomplete

[php]<?php
include_once ‘dbConfig.php’;
//$diagnosis = "SELECT diagnosis FROM medications LIMIT $diagnos
$query="SELECT diagnosis FROM medications ";
$result= $con->query($query);
?>
<?php
$pac = new C_PhpAutocomplete(‘disease’);
$pac -> display(SELECT);
$pac -> set_placeholder(‘select diagnosis’);
?>
<?php
$pac = new C_PhpAutocomplete(‘medication’);
$pac -> display(SELECT);
$pac -> set_placeholder(‘select medication/procedure/service’);
?>

Select Disease
<?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>

                        <option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option> 
                  <?php } ?> 
                     </select>
               <?php  
                 $query="SELECT prescription FROM medications ";
                 $result= $con->query($query);
                ?>  
                      <select id="medication" style="width: 30%; margin-left: 5%;" name="prescription" required="true" data-toggle="tooltip" data-original-title="medications" class="date-picker form-control col-md-7 col-xs-12" data-rel="chosen">
                       <option value="">Select Medication/Procedure/Service</option>
                         <?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>
                        <option value="<?php echo $row['prescription']?>"><?php echo $row['prescription'];?> </option> 
                  <?php } ?> 
                     </select> 

[/php]
wireframes??

That is all kinds of bad actually.

If you wrote that, what i am about to say will probably have you really wondering.

You meed a diagnosis/ procedures/ HCPCS API that feeds your application.

:o :o :o you are right it really got me wondering, and thanks for this new knowledge, i looked it up and it does seem like its extcly what i will need for this application to work, problem is going to be embedding it on the application

Look into the slim api framework to start with. If you want to get better at php in general, Laravel framework.

okay thanks mate

will check them out

cheers

Sponsor our Newsletter | Privacy Policy | Terms of Service