[Resolvido] Ordem Alfabética relatório puxando nome por ID
queria saber como organizar esse relatório em ordem alfabética sendo q os registros são armazenados com o ID dos cadastros ai recupero o nome pelo id segue codigo abaixo
<?php
function converter_data2($strData) {
// Recebemos a data no formato: dd/mm/aaaa
// Convertemos a data para o formato: aaaa-mm-dd
if ( preg_match("#-#",$strData) == 1 ) {
$strDataFinal = implode('/', array_reverse(explode('-',$strData)));
}
return $strDataFinal;
}
function converter_data($strData) {
// Recebemos a data no formato: dd/mm/aaaa
// Convertemos a data para o formato: aaaa-mm-dd
if ( preg_match("#/#",$strData) == 1 ) {
$strDataFinal = "'";
$strDataFinal .= implode('-', array_reverse(explode('/',$strData)));
$strDataFinal .= "'";
}
return $strDataFinal;
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$colname_Recordset1 = "-1";
if (isset($_POST['datainicial'])) {
$colname_Recordset1 = $_POST['datainicial'];
}
$datafinal_Recordset1 = "-1";
if (isset($_POST['datafinal'])) {
$datafinal_Recordset1 = $_POST['datafinal'];
}
mysql_select_db($database_conect, $conect);
$query_Recordset1 = sprintf("SELECT * FROM doacoes WHERE `data` >= %s AND doacoes.`data` <= %s ORDER BY `data` ASC", converter_data($colname_Recordset1, "date"),converter_data($datafinal_Recordset1, "date"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sem título</title>
</head>
<body>
<table width="652" border="1" align="center">
<tr>
<td width="35">id</td>
<td width="285">Nome</td>
<td width="79">Valor</td>
<td width="125">Cidade</td>
<td width="94">Data</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['id']; ?></td>
<td><?php $doador_id = $row_Recordset1['doador_id'];
mysql_select_db($database_conect, $conect);
$query_nomedoador = "SELECT * FROM doadores WHERE id =".$row_Recordset1['doador_id']."";
$nomedoador = mysql_query($query_nomedoador, $conect) or die(mysql_error());
$row_nomedoador = mysql_fetch_assoc($nomedoador);
$totalRows_nomedoador = mysql_num_rows($nomedoador);
echo $row_nomedoador['nome']; ?>
</td>
<td><?php echo $row_Recordset1['valor']; ?></td>
<td><?php echo $row_Recordset1['cidade']; ?></td>
<td><?php echo converter_data2($row_Recordset1['data']); ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p> </p>
<p><br />
</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>Discussão (4)
Carregando comentários...