morena Posted January 10, 2017 Share Posted January 10, 2017 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> Quote Link to comment Share on other sites More sharing options...
benanamen Posted January 10, 2017 Share Posted January 10, 2017 (edited) 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 January 10, 2017 by benanamen Quote Link to comment Share on other sites More sharing options...
Barand Posted January 10, 2017 Share Posted January 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
benanamen Posted January 10, 2017 Share Posted January 10, 2017 (edited) 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 January 10, 2017 by benanamen Quote Link to comment Share on other sites More sharing options...
morena Posted January 10, 2017 Author Share Posted January 10, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.