Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php error in displaying large database

Status
Not open for further replies.

callshakeel

Programmer
Apr 11, 2003
10
IN
plz help me,

i want to display records of more than 500 person in a table of 500 * 25 ,but while displaying php get slow and gives error and don't print all records it prints some of them,
If there are less the 100 records in the database it works fine
I'm using IIS server and SQL server for database, i'm fetching the records from two or three databases so i'v to use nested while loop .
i'v increased the Maximum execution time to 120 sec. and increased the virtual paging size.
but still it is not printing and takes too much time to print some of records not all and break and gives error


the code for printing is here.....


$qstr = "SELECT username FROM tblRoles WHERE stu='1'";
$result = $conn->Execute($qstr);
while(!$result->EOF){
$objStu = $result->Fields(0);
$strStu = $objStu->value;
echo &quot;<TR>&quot;;

$qstr1 = &quot;SELECT DISTINCT cpi FROM tblPreference WHERE username='$strStu' AND acYearFrom='$strYrFrom' AND semester='$strSem'&quot;;
$res1 = $conn->Execute($qstr1);
if (!$res1->EOF){
while(!$res1->EOF){
$objCPI=$res1->Fields(0);
$strCPI=$objCPI->value;
echo &quot;<TD CLASS = \&quot;smallElement\&quot; id=\&quot;$strStu\&quot;>$strStu</TD>&quot;;
echo &quot;<TD CLASS = \&quot;smallElement\&quot;>$strCPI</TD>&quot;;
echo &quot;<TD CLASS=\&quot;smallSubTitle\&quot; width=\&quot;0\&quot;></td>&quot;;
$res1->MoveNext();
}
}else{
echo &quot;<TD CLASS = \&quot;smallElement\&quot; id=\&quot;$strStu\&quot;>$strStu</TD>&quot;;
echo &quot;<TD CLASS = \&quot;smallElement\&quot;>&nbsp;</TD>&quot;;
echo &quot;<TD CLASS=\&quot;smallsubTitle\&quot; width=\&quot;0\&quot;></td>&quot;;
}

$qstr2 = &quot;SELECT workID FROM tblWorks WHERE acYearFrom='$strYrFrom' AND semester='$strSem'&quot;;
$res2 = $conn->Execute($qstr2);
while(!$res2->EOF){
$objWork=$res2->Fields(0);
$strWork=$objWork->value;

$qstr3 = &quot;SELECT preference, status FROM tblPreference WHERE username='$strStu' AND WorkID='$strWork'&quot;;
$res3 = $conn->Execute($qstr3);
if( !$res3->EOF){

while(!$res3->EOF){

$objPre=$res3->Fields(0);
$strPre=$objPre->value;
$objStatus=$res3->Fields(1);
$strStatus=$objStatus->value;

if ($strStatus == 1){

echo &quot;<TD Class=\&quot;smallElement\&quot; ><font color=\&quot;red\&quot;>$strPre</font><input type=\&quot;radio\&quot; id=\&quot;$radioID\&quot; name=\&quot;$strStu\&quot; value=\&quot;$strWork\&quot; onClick=\&quot;selected(null,$NOR,$NOC,$radioID,this.name);\&quot; checked></td>&quot;;
echo &quot;<script language=\&quot;javascript\&quot;>changeAllotedColor('$strStu')</script>&quot;;
$radioID++;

}else{

echo &quot;<TD Class=\&quot;smallElement\&quot; ><font color=\&quot;red\&quot;>$strPre</font><input type=\&quot;radio\&quot; id=\&quot;$radioID\&quot; name=\&quot;$strStu\&quot; value=\&quot;$strWork\&quot; onClick=\&quot;selected(null,$NOR,$NOC,$radioID,this.name);\&quot; ></td>&quot;;
$radioID++;
}
$res3->MoveNext();
}
}else{

echo &quot;<TD Class=\&quot;smallElement\&quot; ><input type=\&quot;radio\&quot; id=\&quot;$radioID\&quot; name=\&quot;$strStu\&quot; value=\&quot;$strWork\&quot; onClick=\&quot;selected(null,$NOR,$NOC,$radioID,this.name);\&quot;></td>&quot;;
$radioID++;

}
$res2->MoveNext();
}
echo &quot;</TR>&quot;;
$result->MoveNext();
}


 
Try inserting this line at the begining of ur script
ie
set_time_limit(0) ;
this will remove the time limit constraint for which ur script is allowed to run.



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
thanks for ur consideration
i used syntax set_time_limit(0); but there is no effect the problem is same
 
Have you considered optimizing your SQL code?
Are the tables indexed appropriately to allow for faster selects?

I suggest to monitor the SQL server performance and detect where the bottleneck is.
 
plz tell me how to optimize SQl code.
how to index for faster select
how to monitor the server performence
 
Add index in ur query tables mostly on the columns in ur query 'where' part.
Eg if ur query is like
select name from tablename where lname='$lname'
u can add index on column lname.
U can find more info on index on To see if ur query performance (which index its using if at all etc.), use explain


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top