Html grid very slow
Moderator: General Moderators
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Html grid very slow
Hi
I present my data with a html table. I have about 200 records but the show process is very slow.
Here is my code:
echo"<table border='2'>";
echo"<tr>";
echo"<td>";echo"Apagar";echo"</td>";
echo"<td>";echo"Editar";echo"</td>";
echo"<td>";echo"Id";echo"</td>";
echo"<td>";echo "<a href='minhagrid.php?Ordem=";echo "Codigo";echo "'>Código</a>";echo "</td>";
echo"<td>";echo"Designação->";echo"</td>";
echo"<td>";echo"Preco_compra";echo"</td>";
echo"<td>";echo"Preco_venda";echo"</td>";
echo"<td>";echo"Data Compra";echo"</td>";
echo"<td>";echo"Data de Venda";echo"</td>";
echo"</tr>";
while($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>"; echo "<a href='Apagar.php?Id=";echo $row[Id];echo "'>Apagar</a>";echo "</td>";
echo "<td>"; echo "<a href='form/form.php?Id=";echo $row[Id];echo "'>Editar</a>";echo "</td>";
echo "<td>";echo $row['Id'];echo"</td>";
echo "<td>";echo $row['Codigo'];echo"</td>";
echo "<td>";echo $row['Designacao'];echo"</td>";
echo "<td>";echo $row['Preco_compra'];echo"</td>";
echo "<td>";echo $row['Preco_venda'];echo"</td>";
echo "<td>";echo $row['Data_compra'];echo"</td>";
echo "<td>";echo $row['Data_venda'];echo"</td>";
echo"</tr>";
}
echo"</table>";
How can i improve it? Any help?
Thank you
I present my data with a html table. I have about 200 records but the show process is very slow.
Here is my code:
echo"<table border='2'>";
echo"<tr>";
echo"<td>";echo"Apagar";echo"</td>";
echo"<td>";echo"Editar";echo"</td>";
echo"<td>";echo"Id";echo"</td>";
echo"<td>";echo "<a href='minhagrid.php?Ordem=";echo "Codigo";echo "'>Código</a>";echo "</td>";
echo"<td>";echo"Designação->";echo"</td>";
echo"<td>";echo"Preco_compra";echo"</td>";
echo"<td>";echo"Preco_venda";echo"</td>";
echo"<td>";echo"Data Compra";echo"</td>";
echo"<td>";echo"Data de Venda";echo"</td>";
echo"</tr>";
while($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>"; echo "<a href='Apagar.php?Id=";echo $row[Id];echo "'>Apagar</a>";echo "</td>";
echo "<td>"; echo "<a href='form/form.php?Id=";echo $row[Id];echo "'>Editar</a>";echo "</td>";
echo "<td>";echo $row['Id'];echo"</td>";
echo "<td>";echo $row['Codigo'];echo"</td>";
echo "<td>";echo $row['Designacao'];echo"</td>";
echo "<td>";echo $row['Preco_compra'];echo"</td>";
echo "<td>";echo $row['Preco_venda'];echo"</td>";
echo "<td>";echo $row['Data_compra'];echo"</td>";
echo "<td>";echo $row['Data_venda'];echo"</td>";
echo"</tr>";
}
echo"</table>";
How can i improve it? Any help?
Thank you
Re: Html grid very slow
As for speeding it up not sure, but you don't need to echo everything like that. You should get the same result using:
as you did using:
In theory it would speed it up slightly as the computer is reading less. But not significantly, since you're pulling so much data.
Code: Select all
echo"<table border='2'><tr>";
echo"<td>Apagar</td>";
echo"<td>Editar</td>";
echo"<td>Id</td>";
echo"<td><a href='minhagrid.php?Ordem=";echo "Codigo";
echo "'>Código</a></td>";
echo"<td>Designação-></td>";
echo"<td>Preco_compra</td>";
echo"<td>Preco_venda</td>";
echo"<td>Data Compra</td>";
echo"<td>Data de Venda</td>";
echo"</tr>";
Code: Select all
echo"<table border='2'>";
echo"<tr>";
echo"<td>";echo"Apagar";echo"</td>";
echo"<td>";echo"Editar";echo"</td>";
echo"<td>";echo"Id";echo"</td>";
echo"<td>";echo "<a href='minhagrid.php?Ordem=";echo "Codigo";echo "'>Código</a>";echo "</td>";
echo"<td>";echo"Designação->";echo"</td>";
echo"<td>";echo"Preco_compra";echo"</td>";
echo"<td>";echo"Preco_venda";echo"</td>";
echo"<td>";echo"Data Compra";echo"</td>";
echo"<td>";echo"Data de Venda";echo"</td>";
echo"</tr>";-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Html grid very slow
Hi
I think the best option is to paging the results. Unfortunately i don't know how can i do it but i have to study that option, otherwhise the result is very slow.
I think the best option is to paging the results. Unfortunately i don't know how can i do it but i have to study that option, otherwhise the result is very slow.
Re: Html grid very slow
There a number of factors that could be at play here. I doubt your echo has anything to do with it - milliseconds at most. What does your SELECT statement look like? How many joins?
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Html grid very slow
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi JNettles
I tried paging my grid but i don't win much more time. My sql has no joins there it is all the code:
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi JNettles
I tried paging my grid but i don't win much more time. My sql has no joins there it is all the code:
Code: Select all
<?php
$mysql_id = mysql_connect('localhost', "curso", "123");
mysql_select_db('mariolopes',$mysql_id);
$pag = $_GET['pag'];
if (!isset($pag)){
$pag = 1;
}
$resultados = 10;
$query="select * from negocios ";
$result=mysql_query($query);
$resultados_total = mysql_num_rows($result);
$paginas=ceil($resultados_total/$resultados);
$inicio=($pag-1)*$resultados;
if(!isset($_GET[Ordem])){
$query="select * from negocios order by id DESC LIMIT $inicio,$resultados ";//order by id DESC
$result=mysql_query($query);
}
if($_GET[Ordem]="Codigo"){
$query="select * from negocios order by Codigo LIMIT $inicio,$resultados ";//order by Codigo
$result=mysql_query($query);
}
echo"<a href='insereprodutos/forminserir.html'>";echo"Inserir Produto";echo"</a>";
echo"<table border='2'>";
echo"<tr>";
echo"<td>Apagar</td>";
echo"<td>Editar</td>";
echo"<td>Id</td>";
echo"<td>";echo "<a href='minhagrid.php?Ordem=";echo "Codigo";echo "'>Código</a>";echo "</td>";
echo"<td>Designação-></td>";
echo"<td>Preco_compra</td>";
echo"<td>Preco_venda</td>";
echo"<td>Data Compra</td>";
echo"<td>Data de Venda</td>";
echo"</tr>";
while($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>"; echo "<a href='Apagar.php?Id=";echo $row[Id];echo "'>Apagar</a>";echo "</td>";
echo "<td>"; echo "<a href='form/form.php?Id=";echo $row[Id];echo "'>Editar</a>";echo "</td>";
echo "<td>";echo $row['Id'];echo"</td>";
echo "<td>";echo $row['Codigo'];echo"</td>";
echo "<td>";echo $row['Designacao'];echo"</td>";
echo "<td>";echo $row['Preco_compra'];echo"</td>";
echo "<td>";echo $row['Preco_venda'];echo"</td>";
echo "<td>";echo $row['Data_compra'];echo"</td>";
echo "<td>";echo $row['Data_venda'];echo"</td>";
echo"</tr>";
}
echo"</table>";
echo "Pág: ";
for($i=1;$i<=$paginas;$i++){
echo "<a href='minhagrid.php?pag=";echo$i;echo "'>$i</a>";echo "</td>";
}
?>pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Re: Html grid very slow
Simply looking at your SQL I can't see any real issues other than that sometimes using ORDER BY LIMIT can be a bit of a tax but shouldn't be anything really noticeable. Exactly how long is the page taking to fully render?
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Html grid very slow
By so slow do you mean the 4-6 seconds it takes to load?
Re: Html grid very slow
I don't really notice any speed issues honestly - page loaded in under 2 seconds for me. If its taking longer, it could be a hardware issue - check with your web host.
Re: Html grid very slow
Quite likely, I think it loaded slow for me due to video uploads going on constantly on our net connection, still varied and did load faster when the office was quieter. Still anywhere between 3-8 seconds isnt that slow, its just slightly annoyingJNettles wrote:I don't really notice any speed issues honestly - page loaded in under 2 seconds for me. If its taking longer, it could be a hardware issue - check with your web host.