how do i fix my php application making browser unresponsive

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

10-Jan-17 08:18
good day, i have an application which i have developed in php and myslq 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%; 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 Medicatioon</option>
<?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>
<option value="<?php echo $row['prescription']?>"><?php echo $row['prescription'];?> </option>
<?php } ?>
</select>
12-Jan-17 02:37
Why are you loading all the data?

Also, why are you querying the medications database twice?
12-Jan-17 04:02
Never, ever use "SELECT *" in a production system.


It is lazy and amateurish.

[Edited by chrishirst on 12-Jan-17 04:03]

--
Chris.
So long, and thanks for all the fish.
http://webmaster-talk.eu/
12-Jan-17 09:28
well actually i edited that to specific select statements, and i used 2 of them because they retrieve different data from diferent table columns and um selecting all data because its a billing app so doctors have to search for diagnosis and medication so i would not know which ones they will be looking for

i should not use select, then what should i use?
12-Jan-17 12:26
"and i used 2 of them because they retrieve different data from diferent table columns and um selecting all data"

For that you use a JOIN query to select the rows and columns from the tables you need.

"i should not use select, then what should i use?"

It's not the SELECT you should not use ... ... It is the wildcard * selector for ALL columns you should not use.

"SELECT * tablename" means you select every column of every row in the table which may be many thousands of records and huge amounts of data, much of which will be unnecessary.

--
Chris.
So long, and thanks for all the fish.
http://webmaster-talk.eu/
23-Jan-17 04:20
Hi,
Instead of using the sql querries everytime you can use the stored procedures so that the loading time of the website can be reduce.

--
Aakash Patel
ASP.Net Developer
http://www.ifourtechnolab.com
23-Jan-17 06:13
I can only guess that you are confused between caching queries and stored procedures.

--
Chris.
So long, and thanks for all the fish.
http://webmaster-talk.eu/

 
New posts
Old posts

Follow Elated