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!

Page loading really slow

Status
Not open for further replies.

richiwatts

Technical User
Jun 21, 2002
180
GB
One of my pages is taking over 30 seconds to load and there are only 100 records. Is there anything worng with my code? The only thing I have changed recently is surname and mobile

Code:
      <?
      	$usersList = queryDB("select * from users order by boat_place_number, first_name");
      	foreach ($usersList as $k => $udata) {
      		$boatplace = $udata['boat_place_number'] . "";
      		if ($boatplace == '999')
      			$boatplace = '&nbsp;';
      		elseif (strlen($boatplace) == 1) 
			  	$boatplace = "0$boatplace";
//      		$name = utf8_decode(trim($udata['first_name'] . "));
      		if ($name == "") $name = '&nbsp;';
      		$phone = trim($udata['mobile']);
      		if ($phone == "") $phone = '&nbsp;';
      		$email = trim($udata['email']);
      		if ($email == "") $email = '&nbsp;';
      ?>
      <tr>
        <td width="10%" align="center" height="19"><font face="Arial" size="2">
        <?=$boatplace?></font></td>
        <td width="32%" height="19"><font face="Arial" size="2"><?=$udata['first_name'] . " " . $udata['surname']?></font></td>
        <td width="22%" height="19"><font face="Arial" size="2"><?=$phone?></font></td>
        <td width="36%" height="19"><font face="Arial" size="2"><?=$email?></font></td>
      </tr>
      <? } ?>
 
it's unlikely to be the web or database server. why not try timing the code to see where the bottlenecks are. My guess is network latency between your web server and your browser (although tables are innately slow to load).
 
The problem is I have another page in my admin adrea that displays the same info but that page loads within 2 seconds.

Maybe I have to accept this is out of my field.
 
Instead of doing the for each you could do a while right from your query result and step through that way may save some time it would look something like this.
while ($row = mysql_fetch_array($usersList MYSQL_NUM)) {
$row[0] = first db field;
$row[1] = second
}

i dont know if that will help at all kinda hard for me to depect whats going on might save on some processing time though.

Live by the code, Die by the code!!
 
while ($row = mysql_fetch_array($usersList, MYSQL_NUM)) {

typo make sure theres a comma after $userlist or whatever you query result variable is.

Live by the code, Die by the code!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top