Jump to content

how do i fix my php application making browser unresponsive


morena

Recommended Posts

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 
                     include_once 'dbConfig.php';
                     $query="SELECT * FROM medications";
                     $result= $con->query($query);
                    ?>  
                          <select id="nol" style="width: 40%;" name="disease" 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 Disease</option>
                             <?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>
                            <option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option> 
                      <?php } ?> 
                         </select>
  <form method="POST" action="generate-invoive-results-service.php">
  <input type="hidden" name="id" value="<?php echo $id;?>">
   
                   <?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>

Link to comment
Share on other sites

For starters, you don't need two queries to do the same exact thing. Dont SELECT *. Name the columns specifically.

 

You are also opening your form AFTER the first select. In the posted code you don't close the form and there is no submit button.

 

And next time, use the code tags when you post code.

Edited by benanamen
Link to comment
Share on other sites

Given that you are selecting for the prescriptions menu and the disease menu from the same table I would say your "database" (which I am guessing resembles a large spreadsheet) is in great need of normalization.

 

For example, disease names and their ids should be in a separate table, with the disease id being stored in your medication table. This then the table you should be querying to build a menu of diseases.

Link to comment
Share on other sites

Just noticed that you are looking up ICD codes. That data is way to huge to select everything. You are going to have to do something like a chained select where you select a category and work your way down the dropdowns. 

 

@barand makes a good point about the DB structure. What does the current DB look like? One big spreadsheet type table or something else?

Edited by benanamen
Link to comment
Share on other sites

For starters, you don't need two queries to do the same exact thing. Dont SELECT *. Name the columns specifically.

 

You are also opening your form AFTER the first select. In the posted code you don't close the form and there is no submit button.

 

And next time, use the code tags when you post code.

 

Just noticed that you are looking up ICD codes. That data is way to huge to select everything. You are going to have to do something like a chained select where you select a category and work your way down the dropdowns. 

 

@barand makes a good point about the DB structure. What does the current DB look like? One big spreadsheet type table or something else?

 thanks for getting back to me..

 

as for not closing the form i  only took the snipet of the code that actually retrieves the data that im looking for,and even if i narrow the select statement to only select one column it still does the same thing

 

Given that you are selecting for the prescriptions menu and the disease menu from the same table I would say your "database" (which I am guessing resembles a large spreadsheet) is in great need of normalization.

 

For example, disease names and their ids should be in a separate table, with the disease id being stored in your medication table. This then the table you should be querying to build a menu of diseases.

than you will also try that out

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.