Ordenar resultados de una consulta
Publicado por Ross Mary (1 intervención) el 17/04/2013 17:59:04
Por favor necesito su ayuda no tengo muchos conicimientos en php, hice una consulta a tabla de mi base de datos, la estoy mostrando en una tabla y necesito que al hacer click en el nombre de uno de los campos me los ordene de acuerdo a ese campo, pero no tengo ni idea de como hacerlo. Les dejo mi codigo para que vean lo que hice! Gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require("unidades/General.php");
require("/home/content/67/10386767/html/Aplicacion/RS_00001_Encabezado.php");
$Conn = mysql_connect($DNS,$MySQLlogin,$MySQLpassword);
$sql="Select * from empresas";
mysql_select_db($MyDataBase);
$resultado=mysql_query($sql);
if (mysql_num_rows($resultado) > 0)
{
?>
<table width="565" height="91" border="1" cellpadding=2 cellspacing=1>
<TH height="36" COLSPAN=2 ><strong> Listado General de Registros de Empresas</strong></TH>
<tr>
<td width="100"><strong>Código</strong></td>
<td width="100"><strong>Nombre</strong></td>
</tr>
<?php
while ($fila = mysql_fetch_array($resultado))
{
?>
<tr>
<td width="135"><?php echo $fila["Codigo"]; ?></td>
<td width="413"><?php echo $fila["Nombre"]; ?></td>
</tr>
<?php
} ?>
</table>
<div><a href="/Aplicacion/RS_00004_Menu.php"><strong> Atrás </strong></a></div>
<form action="" method="get">
<div align="center"> <input type="button" name="imprimir" value="Imprimir" onClick= "window.print();"/> </div>
</form>
<?php
}else
{
require("/home/content/67/10386767/html/Aplicacion/RS_00001_Encabezado.php");
echo "No hay resultados para esta búsqueda!";
require("/home/content/67/10386767/html/Aplicacion/RS_00002_Pie.php");
}
require("/home/content/67/10386767/html/Aplicacion/RS_00002_Pie.php");
?>
Valora esta pregunta
0