PDA

View Full Version : PAGE IS RUNNING SLOW!!



firemarshall
January 2nd, 2007, 12:13 PM
Could someone please help me??

I've made a tabel in php that corresponds with a mysql database.Now the problem is that it is running very slow. Maybe because i used a wrong loop or is it the query that i'm using?
I only want to show de last 14 rows of de database because it contains much more but i don't want to show that.

I'm using the following code:



<?php
// Connect naar de server and select een database
$link = mysql_connect("blablabla") or die ("could not connect");
mysql_select_db ("blablala") or die ("could not select database");
// Voer Sql query uit
$query= "SELECT * FROM blablabla GROUP BY id DESC LIMIT 14";
$result_handle = mysql_query($query) or die ("Query failed");
/*
Print het resultaat in een HTML tabel
Eerste benadering: krijg het resultaat als een associatief array
*/
print "<table bgcolor='white' width='100%' cellSpacing=0 cellPadding=1 border=0 align='left'>\n
<th bgcolor='363636' width='5'></th>
<th bgcolor='363636' width='100' align='center'><font color='ffffff'>DATUM</font></th>
<th bgcolor='363636' width='5'></th>
<th bgcolor='363636' width='100' align='left'><font color='ffffff'>ARTIEST</font></th>
<th bgcolor='363636' width='95' align='left'><font color='ffffff'>TITEL</font></th>
<th bgcolor='363636' width='100' align='left'><font color='ffffff'>STEMMEN</font></th>
<th bgcolor='363636' width='40'><font color='ffffff'>VS.</font></th>
<th bgcolor='363636' width='5'></th>
<th bgcolor='363636' width='100' align='left'><font color='ffffff'>ARTIEST</font></th>
<th bgcolor='363636' width='95' align='left'><font color='ffffff'>TITEL</font></th>
<th bgcolor='363636' width='100' align='left'><font color='ffffff'>STEMMEN</font></th>
<th bgcolor='363636' width='100' align='center'><font color='ffffff'>WINNAAR</font></th>
<th bgcolor='363636' width='5'></th>
<tr height='5'>\n
</tr>\n
";
$teller = 1;
while ($row = mysql_fetch_array($result_handle,MYSQL_ASSOC)){
if ($teller % 2 == 1) {
print "<tr bgcolor='e6e6e6'>\n";
} else {
print "<tr bgcolor='ffffff'>\n";
}
$teller++;
// lees alle velden van deze rijen uit de database
$datum = $row["datum"];
$artiesteerste = $row["artiest1"];
$titeleerste = $row["titel1"];
$stemmeneerste = $row["stemmen1"];
$plaatjeerste = $row["plaatje1"];
$artiesttwee = $row["artiest2"];
$titeltwee = $row["titel2"];
$stemmentwee = $row["stemmen2"];
$plaatjetwee = $row["plaatje2"];
$winnaar = $row["winnaar"];
// print alle velden in hun respectieve colommen van de tabel
print "<td width='5'></td>\n
<td bgcolor='cccccc' width='100' align='center'>$datum</td>\n
<td width='100' align='center'><img src= $plaatjeerste /></td>\n
<td width='100' align='left'>$artiesteerste</td>\n
<td width='95' align='left'>$titeleerste</td>\n
<td width='100' align='left'>$stemmeneerste</td>\n
<th bgcolor='ffffff' width='40'>VS.</th>\n
<td width='100' align='center'><img src= $plaatjetwee /></td>\n
<td width='100' align='left'>$artiesttwee</td>\n
<td width='95' align='left'>$titeltwee</td>\n
<td width='100' align='left'>$stemmentwee</td>\n
<th bgcolor='fe3baf'width='100' align='center'><font color='ffffff'>$winnaar</font></th>\n
<td width='5'></td>\n
</tr>\n
<tr height='5'>\n
</tr>\n";
}//while
print "</table>\n";
//close connection
mysql_close($link);
?>


Thank u very much!!

bwh2
January 2nd, 2007, 12:40 PM
here's what i would do:

switch your double quotes to single quotes with variable concatenation instead when you print out
remove your GROUP BY because it's not doing anything
remove your styling HTML and use CSS instead

firemarshall
January 3rd, 2007, 09:31 AM
here's what i would do:

switch your double quotes to single quotes with variable concatenation instead when you print out
remove your GROUP BY because it's not doing anything
remove your styling HTML and use CSS instead

I've tried but it doesn't work!! i don't get it!

bwh2
January 3rd, 2007, 10:40 AM
can you show me your new code?

also, where are you testing this? on your own machine or a live server?