I have set a query
with a list resulting from a selection of checkbox
made by the user, the list is with the correct values, as selected, but when checking the content of the result after query in banco de dados
, it is always me displayed one less record.
My list is being set up like this:
// LISTA $colname_rcCandidato = "-1"; if (isset($_GET['list'])) { $colname_rcCandidato = $_GET['list']; }
My search is thus using the list
mysql_select_db($database_pcon, $pcon); $query_rcLista = sprintf("SELECT ongAtleta.IdAtleta, ongAtleta.Nome, ongEscola.Nome AS NomeEscola, ongEscola.Municipio, ongAtleta.ProfResposavel FROM ongAtleta INNER JOIN ongFichaEscolar ON ( ongAtleta.IdAtleta = ongFichaEscolar.IdAtleta ) INNER JOIN ongEscola ON ( ongFichaEscolar.IdEscola = ongEscola.IdEscola ) WHERE ongAtleta.IdAtleta IN (%s)", GetSQLValueString($colname_rcCandidato, "string")); $rcLista = mysql_query($query_rcLista, $pcon) or die(mysql_error()); $row_rcLista = mysql_fetch_assoc($rcLista); $linhas = mysql_num_rows($rcLista);
My export is like this, I'm using classe
PHPExcel
:
if ($linhas > 0) { // Incluimos a classe PHPExcel include '../_comp/externos/classes/PHPExcel.php'; // Instanciamos a classe $objPHPExcel = new PHPExcel(); // Inicializando variável $rowCount = 1; do { $objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, removeAcentos($row_rcLista['Nome'])); $objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, removeAcentos($row_rcLista['NomeEscola'])); $objPHPExcel->getActiveSheet()->SetCellValue('C'.$rowCount, removeAcentos($row_rcLista['ProfResposavel'])); $objPHPExcel->getActiveSheet()->SetCellValue('D'.$rowCount, removeAcentos($row_rcLista['Municipio'])); // Incrementando variável $rowCount++; } while($row_rcLista = mysql_fetch_assoc($rcLista)); // Nome da Planilha $objPHPExcel->getActiveSheet()->setTitle('AlunoEscola'); // Efetua Download header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="RelacaoAlunoEscola.xls"'); header('Cache-Control: max-age=0'); // Se for o IE9, isso talvez seja necessário header('Cache-Control: max-age=1'); // Salvando o Arquivo $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); // Salva diretamente no output $objWriter->save('php://output'); exit; }
In the example I am posting to an image, 4 records are selected and only 3 are displayed in the export.