Forum Moderators: coopster

Message Too Old, No Replies

slow page loading

         

lisa_alias

2:26 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



hi everyone!

another problem : Page is Loading Slow

The problem happens whenever i want to save data into my database and it involves a lot of data into different tables. After i stopped my browser and check my database, the data are saved successfully. That's fine, it just that the time taken for the confirmation page to state that the data are successfully saved is too long, sometimes until the operation timed out.

Is there something wrong about the way i code?

Because i have to use a number of radiobuttons in my form, to save the correct data in the correct fields in my table, i have used some checking method. for example :

if(isset($radio01))
{
<save value into field01>
}
elseif(isset($radio02))
{
<save value into field02>
}

and so on...

or is there more simpler checking method related to radiobuttons? because it involves a lot of data.

sample of my code:

if(isset($submit_nreqform))
{
if($submit_nreqform == "SUBMIT")
{
//Site-by-project
$saveSBP = "update site_by_project set sbp_cp02 = '$sbp_cp02', sbp_cp02_phone = '$sbp_cp02_phone', sbp_cp02_email = '$sbp_cp02_email', sbp_mgt_unit = '$sbp_mgt_unit', sbp_exactroom = '$sbp_exactroom', sbp_nw_ready_by_day = '$nw_ready_day', sbp_nw_ready_by_month = '$nw_ready_month', sbp_nw_ready_by_year = '$nw_ready_year', sbp_nw_test_day = '$nw_test_day', sbp_nw_test_month = '$nw_test_month', sbp_nw_test_year = '$nw_test_year', sbp_current_status = 'NEW', form_complete = '1' where (proj_code = '$proj_code') and (site_code = '$site_code')";

if($dbSBP = mysql_db_query($dbname,$saveSBP,$dblink))

{echo "OK SBP";}

//the rest is about the same, just in different tables (4-5 tables) and involves 10-15 fields each.

//the checking..
//firewall
if($das_firewall == 'y')
{
mysql_db_query($dbname,"update comm_line set das_firewall = 'y' where proj_code = $proj_code and site_code = $site_code",$dblink);
echo "OK firewall y";
}

//the radiobuttons..
//local_user : data : avg
if($lu_data_avg_trans == '1')
{
mysql_db_query($dbname,"update local_user set lu_data_avg_trans = '$lu_data_avg_tweb', lu_data_avg_wpagesize = '0', lu_data_avg_both = '0' where proj_code = $proj_code and site_code = $site_code",$dblink);
}
elseif($lu_data_avg_wpagesize == '1')
{
mysql_db_query($dbname,"update local_user set lu_data_avg_wpagesize = '$lu_data_avg_tweb', lu_data_avg_trans = '0', lu_data_avg_both = '0' where proj_code = $proj_code and site_code = $site_code",$dblink);
}
elseif($lu_data_avg_both == '1')
{
mysql_db_query($dbname,"update local_user set lu_data_avg_both = '$lu_data_avg_tweb', lu_data_avg_trans = '0', lu_data_avg_wpagesize = '0' where proj_code = $proj_code and site_code = $site_code",$dblink);
}

any comments? thanks..

RussellC

3:04 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



I would use mysql_connect() and then mysql_select_db() to connect to the DB and select the DB once, then use mysql_query() to query instead of mysql_db_query() which i think tries to make a connection to the DB each time.

ergophobe

4:39 pm on Jan 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just to mention the obvious... do you have any loops in your script?

lisa_alias

1:13 am on Jan 30, 2004 (gmt 0)

10+ Year Member



hello.. sorry 4 not replying for quite long.

i have already found a solution regarding this page. it was just there were lots of "radiobutton checking" and i have made it simpler with just one shot of inserting the values into my database. did not require any checking. just rename the radiobuttons with same name but set different values to each of them, and then save into the database without checking. More efficient.. :)

some of the pages still have problems especially when it comes to displaying multiple records in a table. yes, this requires loops. i use while loop.
it goes something like this:
<?
$countRow = 0;
while ($nilai = mysql_fetch_array($db))
{
++$countRow;
echo $nilai[0]; //first column in table
echo $nilai[1]; //second column in table
}
mysql_free_result($db);
?>

each record displayed has to perform some checkings on their status in order to display some links attached to it correctly based on a few conditions. these links will allow user to perform spesific functions on that particular record.

for example, a user wants to display all records in a table. he can:

1. edit and view the record if the record info is complete. hence, the links : View n Edit

2. send an email to someone to inform the status of the record if the record info is complete and has not been sent yet. hence, the links : Send

if the records did not fulfill these condition, i.e the user cannot perform any operations on them.

the page is loading slow if there are more than 4 records are involved to be displayed.

how about if there are hundreds of them?