Jump to content
Fórum Script Brasil
  • 0

ORDEM ALFABETICA PHP (não FUNCIONA)


Tuganet

Question

Boa tarde,

tenho um sitema de cadastramento de peça e estou com um problema. E quero que a coluna categorioa fique ordenada de forma alfabetica.

Na listagem dos produtos era ordenar por ordem crescente ou decrescente. mas neste caso a ordem crescente e decrescente não está funcionado. Ele até ordena, mas fica tipo assim:

capacete

capacete

capacete

capacete

pneu

pneu

pneu

bateria

bateria

bateria

lubrificante

Segue o código

<a href="estoquelist.php?order=<?php echo urlencode("categoria"); ?>">

            categoria<?php if (@$_SESSION[ewSessionTblSort . "_x_categoria"] == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_categoria"] == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?>

VALE LEMBRAR QUE SOU LEIGO NO PHP.. RSSS ME VIRO NOS 30 RSSS

SE PUDEREM AJUDAR AGRADEÇO!!!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
Dentro do estoquelist.php, procure a variável $_GET['order'].

Não sei como está sendo feita essa ordenação (se é na busca do banco de dados ou ordenando arrays), por isso poste aqui o que o sistema faz de acordo com o valor dessa variável.

O Massaki.. valeu..

segue o código da pag.

<?php 

session_start();

ob_start();

?>

<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified

header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1

header("Cache-Control: post-check=0, pre-check=0", false);

header("Pragma: no-cache"); // HTTP/1.0

?>

<?php include ("ewconfig.php") ?>

<?php include ("db.php") ?>

<?php include ("estoqueinfo.php") ?>

<?php include ("advsecu.php") ?>

<?php include ("phpmkrfn.php") ?>

<?php include ("ewupload.php") ?>

<?php

if (!IsLoggedIn()) {

ob_end_clean();

header("Location: login.php");

exit();

}

?>

<?php



// Initialize common variables

$x_Tipo = NULL;

$ox_Tipo = NULL;

$z_Tipo = NULL;

$ar_x_Tipo = NULL;

$ari_x_Tipo = NULL;

$x_TipoList = NULL;

$x_TipoChk = NULL;

$cbo_x_Tipo_js = NULL;

$x_anuncio = NULL;

$ox_anuncio = NULL;

$z_anuncio = NULL;

$ar_x_anuncio = NULL;

$ari_x_anuncio = NULL;

$x_anuncioList = NULL;

$x_anuncioChk = NULL;

$cbo_x_anuncio_js = NULL;

$x_Id_estoque = NULL;

$ox_Id_estoque = NULL;

$z_Id_estoque = NULL;

$ar_x_Id_estoque = NULL;

$ari_x_Id_estoque = NULL;

$x_Id_estoqueList = NULL;

$x_Id_estoqueChk = NULL;

$cbo_x_Id_estoque_js = NULL;

$x_id_plano = NULL;

$ox_id_plano = NULL;

$z_id_plano = NULL;

$ar_x_id_plano = NULL;

$ari_x_id_plano = NULL;

$x_id_planoList = NULL;

$x_id_planoChk = NULL;

$cbo_x_id_plano_js = NULL;

$x_data_cadastro = NULL;

$ox_data_cadastro = NULL;

$z_data_cadastro = NULL;

$ar_x_data_cadastro = NULL;

$ari_x_data_cadastro = NULL;

$x_data_cadastroList = NULL;

$x_data_cadastroChk = NULL;

$cbo_x_data_cadastro_js = NULL;

$x_data = NULL;

$ox_data = NULL;

$z_data = NULL;

$ar_x_data = NULL;

$ari_x_data = NULL;

$x_dataList = NULL;

$x_dataChk = NULL;

$cbo_x_data_js = NULL;

$x_id_membro = NULL;

$ox_id_membro = NULL;

$z_id_membro = NULL;

$ar_x_id_membro = NULL;

$ari_x_id_membro = NULL;

$x_id_membroList = NULL;

$x_id_membroChk = NULL;

$cbo_x_id_membro_js = NULL;

$x_categoria = NULL;

$ox_categoria = NULL;

$z_categoria = NULL;

$ar_x_categoria = NULL;

$ari_x_categoria = NULL;

$x_categoriaList = NULL;

$x_categoriaChk = NULL;

$cbo_x_categoria_js = NULL;

$x_marcas = NULL;

$ox_marcas = NULL;

$z_marcas = NULL;

$ar_x_marcas = NULL;

$ari_x_marcas = NULL;

$x_marcasList = NULL;

$x_marcasChk = NULL;

$cbo_x_marcas_js = NULL;

$x_marca = NULL;

$ox_marca = NULL;

$z_marca = NULL;

$ar_x_marca = NULL;

$ari_x_marca = NULL;

$x_marcaList = NULL;

$x_marcaChk = NULL;

$cbo_x_marca_js = NULL;

$x_ano = NULL;

$ox_ano = NULL;

$z_ano = NULL;

$ar_x_ano = NULL;

$ari_x_ano = NULL;

$x_anoList = NULL;

$x_anoChk = NULL;

$cbo_x_ano_js = NULL;

$x_ano2 = NULL;

$ox_ano2 = NULL;

$z_ano2 = NULL;

$ar_x_ano2 = NULL;

$ari_x_ano2 = NULL;

$x_ano2List = NULL;

$x_ano2Chk = NULL;

$cbo_x_ano2_js = NULL;

$x_cor = NULL;

$ox_cor = NULL;

$z_cor = NULL;

$ar_x_cor = NULL;

$ari_x_cor = NULL;

$x_corList = NULL;

$x_corChk = NULL;

$cbo_x_cor_js = NULL;

$x_preco = NULL;

$ox_preco = NULL;

$z_preco = NULL;

$ar_x_preco = NULL;

$ari_x_preco = NULL;

$x_precoList = NULL;

$x_precoChk = NULL;

$cbo_x_preco_js = NULL;

$x_cidade = NULL;

$ox_cidade = NULL;

$z_cidade = NULL;

$ar_x_cidade = NULL;

$ari_x_cidade = NULL;

$x_cidadeList = NULL;

$x_cidadeChk = NULL;

$cbo_x_cidade_js = NULL;

$x_km = NULL;

$ox_km = NULL;

$z_km = NULL;

$ar_x_km = NULL;

$ari_x_km = NULL;

$x_kmList = NULL;

$x_kmChk = NULL;

$cbo_x_km_js = NULL;

$x_placa = NULL;

$ox_placa = NULL;

$z_placa = NULL;

$ar_x_placa = NULL;

$ari_x_placa = NULL;

$x_placaList = NULL;

$x_placaChk = NULL;

$cbo_x_placa_js = NULL;

$x_condicoes = NULL;

$ox_condicoes = NULL;

$z_condicoes = NULL;

$ar_x_condicoes = NULL;

$ari_x_condicoes = NULL;

$x_condicoesList = NULL;

$x_condicoesChk = NULL;

$cbo_x_condicoes_js = NULL;

$x_portas = NULL;

$ox_portas = NULL;

$z_portas = NULL;

$ar_x_portas = NULL;

$ari_x_portas = NULL;

$x_portasList = NULL;

$x_portasChk = NULL;

$cbo_x_portas_js = NULL;

$x_combustivel = NULL;

$ox_combustivel = NULL;

$z_combustivel = NULL;

$ar_x_combustivel = NULL;

$ari_x_combustivel = NULL;

$x_combustivelList = NULL;

$x_combustivelChk = NULL;

$cbo_x_combustivel_js = NULL;

$x_transmissao = NULL;

$ox_transmissao = NULL;

$z_transmissao = NULL;

$ar_x_transmissao = NULL;

$ari_x_transmissao = NULL;

$x_transmissaoList = NULL;

$x_transmissaoChk = NULL;

$cbo_x_transmissao_js = NULL;

$x_descricao = NULL;

$ox_descricao = NULL;

$z_descricao = NULL;

$ar_x_descricao = NULL;

$ari_x_descricao = NULL;

$x_descricaoList = NULL;

$x_descricaoChk = NULL;

$cbo_x_descricao_js = NULL;

$x_oferta = NULL;

$ox_oferta = NULL;

$z_oferta = NULL;

$ar_x_oferta = NULL;

$ari_x_oferta = NULL;

$x_ofertaList = NULL;

$x_ofertaChk = NULL;

$cbo_x_oferta_js = NULL;

$x_exibir = NULL;

$ox_exibir = NULL;

$z_exibir = NULL;

$ar_x_exibir = NULL;

$ari_x_exibir = NULL;

$x_exibirList = NULL;

$x_exibirChk = NULL;

$cbo_x_exibir_js = NULL;

$x_avisado = NULL;

$ox_avisado = NULL;

$z_avisado = NULL;

$ar_x_avisado = NULL;

$ari_x_avisado = NULL;

$x_avisadoList = NULL;

$x_avisadoChk = NULL;

$cbo_x_avisado_js = NULL;

$x_entrada = NULL;

$ox_entrada = NULL;

$z_entrada = NULL;

$ar_x_entrada = NULL;

$ari_x_entrada = NULL;

$x_entradaList = NULL;

$x_entradaChk = NULL;

$cbo_x_entrada_js = NULL;

$x_qtd_parcelas = NULL;

$ox_qtd_parcelas = NULL;

$z_qtd_parcelas = NULL;

$ar_x_qtd_parcelas = NULL;

$ari_x_qtd_parcelas = NULL;

$x_qtd_parcelasList = NULL;

$x_qtd_parcelasChk = NULL;

$cbo_x_qtd_parcelas_js = NULL;

$x_valor_parcelas = NULL;

$ox_valor_parcelas = NULL;

$z_valor_parcelas = NULL;

$ar_x_valor_parcelas = NULL;

$ari_x_valor_parcelas = NULL;

$x_valor_parcelasList = NULL;

$x_valor_parcelasChk = NULL;

$cbo_x_valor_parcelas_js = NULL;

$x_contato = NULL;

$ox_contato = NULL;

$z_contato = NULL;

$ar_x_contato = NULL;

$ari_x_contato = NULL;

$x_contatoList = NULL;

$x_contatoChk = NULL;

$cbo_x_contato_js = NULL;

$x_acessos = NULL;

$ox_acessos = NULL;

$z_acessos = NULL;

$ar_x_acessos = NULL;

$ari_x_acessos = NULL;

$x_acessosList = NULL;

$x_acessosChk = NULL;

$cbo_x_acessos_js = NULL;

?>

<?php

$nStartRec = 0;

$nStopRec = 0;

$nTotalRecs = 0;

$nRecCount = 0;

$nRecActual = 0;

$sKeyMaster = "";

$sDbWhereMaster = "";

$sSrchAdvanced = "";

$psearch = "";

$psearchtype = "";

$sDbWhereDetail = "";

$sSrchBasic = "";

$sSrchWhere = "";

$sDbWhere = "";

$sOrderBy = "";

$sSqlMaster = "";

$sListTrJs = "";

$bEditRow = "";

$nEditRowCnt = "";

$sDeleteConfirmMsg = "";

$bMasterRecordExist = false;

$x_id = NULL;

$ox_id = NULL;

$x_id_marca = NULL;

$ox_id_marca = NULL;

$x_modelo = NULL;

$ox_modelo = NULL;

$nDisplayRecs = "400050";

$nRecRange = 10;



// Open connection to the database

$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);



// Handle reset command

ResetCmd();



// Set up master detail parameters

SetUpMasterDetail();



// Get search criteria for Basic (Quick) Search

$psearch = (!get_magic_quotes_gpc()) ? addslashes(@$_GET[ewTblBasicSrch]) : @$_GET[ewTblBasicSrch];

$psearchtype = @$_GET[ewTblBasicSrchType];

SetUpBasicSearch();



// Build search criteria

if ($sSrchAdvanced != "") {

if ($sSrchWhere <> "") $sSrchWhere .= " AND ";

$sSrchWhere .= "(" . $sSrchAdvanced . ")"; // Advanced Search

}

if ($sSrchBasic != "") {

if ($sSrchWhere <> "") $sSrchWhere .= " AND ";

$sSrchWhere .= "(" . $sSrchBasic . ")"; // Basic Search

}



// Save search criteria

if ($sSrchWhere != "") {

$_SESSION[ewSessionTblSearchWhere] = $sSrchWhere;



// Reset start record counter (new search)

$nStartRec = 1;

$_SESSION[ewSessionTblStartRec] = $nStartRec;

} else {

$sSrchWhere = @$_SESSION[ewSessionTblSearchWhere];

RestoreSearch();

}



// Build filter condition

$sDbWhere = "";

if ($sDbWhereDetail <> "") {

if ($sDbWhere <> "") $sDbWhere .= " AND ";

$sDbWhere .= "(" . $sDbWhereDetail . ")";

}

if ($sSrchWhere <> "") {

if ($sDbWhere <> "") $sDbWhere .= " AND ";

$sDbWhere .= "(" . $sSrchWhere . ")";

}



// Set up sorting order

$sOrderBy = "";

SetUpSortOrder();

$sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sDbWhere, $sOrderBy);



// echo $sSql . "<br>"; // Uncomment to show SQL for debugging

// Build master record SQL



if ($sDbWhereMaster <> "") {

$sSqlMaster = ewBuildSql(ewSqlMasterSelect, ewSqlMasterWhere, ewSqlMasterGroupBy, ewSqlMasterHaving, ewSqlMasterOrderBy, $sDbWhereMaster, "");

$rs = phpmkr_query($sSqlMaster, $conn) or die("Falha ao executar consulta." . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSqlMaster);

$bMasterRecordExist = (phpmkr_num_rows($rs) > 0);

if (!$bMasterRecordExist) {

$_SESSION[ewSessionTblMasterWhere] = "";

$_SESSION[ewSessionTblDetailWhere] = "";

$_SESSION[ewSessionMessage] = "Nenhum registro encontrado";

phpmkr_free_result($rs);

phpmkr_db_close($conn);

header("Location: modelolist.php");

exit();

}

}

?>

<?php include ("header.php") ?>

<script type="text/javascript">

<!--

EW_LookupFn = "ewlookup.php"; // ewlookup file name

EW_AddOptFn = "ewaddopt.php"; // ewaddopt.php file name



//-->

</script>

<script type="text/javascript" src="ewp.js"></script>

<script type="text/javascript">

<!--

EW_dateSep = "/"; // set date separator

EW_UploadAllowedFileExt = "gif,jpg,jpeg,bmp,png,doc,xls,pdf,zip"; // allowed upload file extension



//-->

</script>

<script type="text/javascript">

<!--

var firstrowoffset = 1; // first data row start at

var tablename = 'ewlistmain'; // table name

var lastrowoffset = 0; // footer row

var usecss = true; // use css

var rowclass = 'ewTableRow'; // row class

var rowaltclass = 'ewTableAltRow'; // row alternate class

var rowmoverclass = 'ewTableHighlightRow'; // row mouse over class

var rowselectedclass = 'ewTableSelectRow'; // row selected class

var roweditclass = 'ewTableEditRow'; // row edit class

var rowcolor = '#FFFFFF'; // row color

var rowaltcolor = '#F5F5F5'; // row alternate color

var rowmovercolor = '#FFCCFF'; // row mouse over color

var rowselectedcolor = '#CCFFFF'; // row selected color

var roweditcolor = '#FFFF99'; // row edit color



//-->

</script>

<script type="text/javascript">

<!--

var EW_DHTMLEditors = [];



//-->

</script>

<?php

if ($sDbWhereMaster <> "") {

if ($bMasterRecordExist) { ?>

<p><span class="phpmaker">Registro principal: MODELOS

<br><a href="modelolist.php">Voltar à lista principal</a></span>

</p>

<table class="ewTable">

<tr class="ewTableHeader">

<td valign="top"><span>marca</span></td>

<td valign="top"><span>modelo</span></td>

</tr>

<tr class="ewTableSelectRow">

<?php

$row = phpmkr_fetch_array($rs);

$x_id = $row["id"];

$x_id_marca = $row["id_marca"];

$x_modelo = $row["modelo"];

?>

<td><span>

<?php

if ((!is_null($x_id_marca)) && ($x_id_marca <> "")) {

$sSqlWrk = "SELECT `marca` FROM `marca`";

$sTmp = $x_id_marca;

$sTmp = addslashes($sTmp);

$sSqlWrk .= " WHERE `Id_marca` = " . $sTmp . "";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Falha ao executar consulta." . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk && $rowwrk = phpmkr_fetch_array($rswrk)) {

$sTmp = $rowwrk["marca"];

}

@phpmkr_free_result($rswrk);

} else {

$sTmp = "";

}

$ox_id_marca = $x_id_marca; // Backup original value

$x_id_marca = $sTmp;

?>

<?php echo $x_id_marca; ?>

<?php $x_id_marca = $ox_id_marca; // Restore original value ?>

</span></td>

<td><span>

<?php echo $x_modelo; ?>

</span></td>

</tr>

</table>

<br>

<?php

}

phpmkr_free_result($rs);

}

?>

<?php



// Set up recordset

$rs = phpmkr_query($sSql, $conn) or die("Falha ao executar consulta." . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql);

$nTotalRecs = phpmkr_num_rows($rs);

if ($nDisplayRecs <= 0) { // Display all records

$nDisplayRecs = $nTotalRecs;

}

$nStartRec = 1;

SetUpStartRec(); // Set up start record position

?>

<p><span class="phpmaker">Sessão: LISTAGEM DE AN&Uacute;NCIOS</span></p>

<form id="festoquelistsrch" name="festoquelistsrch" action="estoquelist.php" >

<table class="ewBasicSearch">

<tr>

<td><span class="phpmaker">

<input type="text" name="<?php echo ewTblBasicSrch; ?>" size="20" value="<?php echo $psearch;?>">

<input type="Submit" name="Submit" value="Busca&nbsp;(*)">&nbsp;

<input type="Button" name="Reset" value="Limpar" onclick="EW_clearForm(this.form);this.form.<?php echo ewTblBasicSrchType;?>[0].checked = true;">&nbsp;

<a href="estoquelist.php?cmd=reset">Mostrar todas</a>&nbsp;

</span></td>

</tr>

<tr>

<td><span class="phpmaker"><input type="radio" name="<?php echo ewTblBasicSrchType;?>" value="" <?php if ($psearchtype == "") { ?>checked<?php } ?>>frase exata&nbsp;&nbsp;<input type="radio" name="<?php echo ewTblBasicSrchType; ?>" value="AND" <?php if ($psearchtype == "AND") { ?>checked<?php } ?>>todas as palavras&nbsp;&nbsp;<input type="radio" name="<?php echo ewTblBasicSrchType; ?>" value="OR" <?php if ($psearchtype == "OR") { ?>checked<?php } ?>>qualquer palavra</span></td>

</tr>

</table>

</form>

<table class="ewListAdd">

<tr>

<td><span class="phpmaker"><a href="estoqueadd.php"><img src='images/add.gif' alt='Adicionar' border='0'></a></span></td>

</tr>

</table>

<p>

<?php

if (@$_SESSION[ewSessionMessage] <> "") {

?>

<p><span class="ewmsg"><?php echo $_SESSION[ewSessionMessage]; ?></span></p>

<?php

$_SESSION[ewSessionMessage] = ""; // Clear message

}

?>

<?php if ($nTotalRecs > 0) { ?>

<form method="post">

<table id="ewlistmain" class="ewTable">

<!-- Table header -->

<tr class="ewTableHeader">

<td colspan="8" valign="top">cLIQUE NO TITULO DA COLUNA - PARA LISTAR EM ORDEM CRESCENTE OU DECRESCENTE ***CADA COLUNA***.</td>

<td>&nbsp;</td>

</tr>

<tr class="ewTableHeader">

<td valign="top"><span>

<a href="estoquelist.php?order=<?php echo urlencode("Id_estoque"); ?>">

Id<?php if (@$_SESSION[ewSessionTblSort . "_x_Id_estoque"] == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_Id_estoque"] == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?>

</a>

</span></td>

<td valign="top"><span>

<a href="estoquelist.php?order=<?php echo urlencode("categoria"); ?>">

categoria<?php if (@$_SESSION[ewSessionTblSort . "_x_categoria"] == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_categoria"] == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?>

</a>

</span></td>

<td valign="top"><span>

<a href="estoquelist.php?order=<?php echo urlencode("marcas"); ?>">

marcas<?php if (@$_SESSION[ewSessionTblSort . "_x_marcas"] == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_marcas"] == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?>

</a>

</span></td>

<td valign="top"><span>

<a href="estoquelist.php?order=<?php echo urlencode("marca"); ?>">

modelo<?php if (@$_SESSION[ewSessionTblSort . "_x_marca"] == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_marca"] == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?>

</a>

</span></td>

<td valign="top"><span>

<a href="estoquelist.php?order=<?php echo urlencode("exibir"); ?>">

exibir<?php if (@$_SESSION[ewSessionTblSort . "_x_exibir"] == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_exibir"] == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?>

</a>

</span></td>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td>&nbsp;</td>

</tr>

<?php



// Set the last record to display

$nStopRec = $nStartRec + $nDisplayRecs - 1;



// Move to the first record

$nRecCount = $nStartRec - 1;

if (phpmkr_num_rows($rs) > 0) {

phpmkr_data_seek($rs, $nStartRec -1);

}

$nRecActual = 0;

while (($row = @phpmkr_fetch_array($rs)) && ($nRecCount < $nStopRec)) {

$nRecCount = $nRecCount + 1;

if ($nRecCount >= $nStartRec) {

$nRecActual++;



// Set row color

$sItemRowClass = " class=\"ewTableRow\"";

$sListTrJs = " onmouseover='ew_mouseover(this);' onmouseout='ew_mouseout(this);' onclick='ew_click(this);'";



// Display alternate color for rows

if ($nRecCount % 2 <> 1) {

$sItemRowClass = " class=\"ewTableAltRow\"";

}

$x_Tipo = $row["Tipo"];

$x_anuncio = $row["anuncio"];

$x_Id_estoque = $row["Id_estoque"];

$x_id_plano = $row["id_plano"];

$x_data_cadastro = $row["data_cadastro"];

$x_data = $row["data"];

$x_id_membro = $row["id_membro"];

$x_categoria = $row["categoria"];

$x_marcas = $row["marcas"];

$x_marca = $row["marca"];

$x_ano = $row["ano"];

$x_ano2 = $row["ano2"];

$x_cor = $row["cor"];

$x_preco = $row["preço"];

$x_cidade = $row["cidade"];

$x_km = $row["km"];

$x_placa = $row["placa"];

$x_condicoes = $row["condicoes"];

$x_portas = $row["portas"];

$x_combustivel = $row["combustivel"];

$x_transmissao = $row["transmissao"];

$x_descricao = $row["descricao"];

$x_oferta = $row["oferta"];

$x_exibir = $row["exibir"];

$x_avisado = $row["avisado"];

$x_entrada = $row["entrada"];

$x_qtd_parcelas = $row["qtd_parcelas"];

$x_valor_parcelas = $row["valor_parcelas"];

$x_contato = $row["contato"];

$x_acessos = $row["acessos"];

?>

<!-- Table body -->

<tr<?php echo $sItemRowClass; ?><?php echo $sListTrJs; ?>>

<!-- anuncio -->

<!-- Id_estoque -->

<td><span>

<?php echo $x_Id_estoque; ?>

</span></td>

<!-- id_plano -->

<!-- data_cadastro -->

<!-- data -->

<!-- categoria -->

<td><span>

<?php

if ((!is_null($x_categoria)) && ($x_categoria <> "")) {

$sSqlWrk = "SELECT `categoria` FROM `categorias`";

$sTmp = $x_categoria;

$sTmp = addslashes($sTmp);

$sSqlWrk .= " WHERE `id` = " . $sTmp . "";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Falha ao executar consulta." . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk && $rowwrk = phpmkr_fetch_array($rswrk)) {

$sTmp = $rowwrk["categoria"];

}

@phpmkr_free_result($rswrk);

} else {

$sTmp = "";

}

$ox_categoria = $x_categoria; // Backup original value

$x_categoria = $sTmp;

?>

<?php echo $x_categoria; ?>

<?php $x_categoria = $ox_categoria; // Restore original value ?>

</span></td>

<!-- marcas -->

<td><span>

<?php

if ((!is_null($x_marcas)) && ($x_marcas <> "")) {

$sSqlWrk = "SELECT `marca` FROM `marca`";

$sTmp = $x_marcas;

$sTmp = addslashes($sTmp);

$sSqlWrk .= " WHERE `Id_marca` = " . $sTmp . "";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Falha ao executar consulta." . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk && $rowwrk = phpmkr_fetch_array($rswrk)) {

$sTmp = $rowwrk["marca"];

}

@phpmkr_free_result($rswrk);

} else {

$sTmp = "";

}

$ox_marcas = $x_marcas; // Backup original value

$x_marcas = $sTmp;

?>

<?php echo $x_marcas; ?>

<?php $x_marcas = $ox_marcas; // Restore original value ?>

</span></td>

<!-- marca -->

<td><span>

<?php

if ((!is_null($x_marca)) && ($x_marca <> "")) {

$sSqlWrk = "SELECT `modelo` FROM `modelo`";

$sTmp = $x_marca;

$sTmp = addslashes($sTmp);

$sSqlWrk .= " WHERE `id` = " . $sTmp . "";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Falha ao executar consulta." . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk && $rowwrk = phpmkr_fetch_array($rswrk)) {

$sTmp = $rowwrk["modelo"];

}

@phpmkr_free_result($rswrk);

} else {

$sTmp = "";

}

$ox_marca = $x_marca; // Backup original value

$x_marca = $sTmp;

?>

<?php echo $x_marca; ?>

<?php $x_marca = $ox_marca; // Restore original value ?>

</span></td>

<!-- exibir -->

<td><span>

<?php

switch ($x_exibir) {

case "Sim":

$sTmp = "Sim";

break;

case "Não":

$sTmp = "Não";

break;

default:

$sTmp = "";

}

$ox_exibir = $x_exibir; // Backup original value

$x_exibir = $sTmp;

?>

<?php echo $x_exibir; ?>

<?php $x_exibir = $ox_exibir; // Restore original value ?>

</span></td>

<td><span class="phpmaker"><a href="<?php if ($x_Id_estoque <> "") {echo "estoqueedit.php?Id_estoque=" . urlencode($x_Id_estoque); } else { echo "java script:alert('Registro inválido! Chave nula');";} ?>"><img src='images/edit.gif' alt='Editar' border='0'></a></span></td>

<td><span class="phpmaker"><a href="<?php if ($x_Id_estoque <> "") {echo "estoquedelete.php?Id_estoque=" . urlencode($x_Id_estoque); } else { echo "java script:alert('Registro inválido! Chave nula');";} ?>"><img src='images/excluir.gif' alt='Delete' border='0'></a></span></td>

<td><span class="phpmaker"><a href="fotoslist.php?showmaster=1&id_estoque=<?php echo urlencode($x_Id_estoque); ?>">FOTOS </a></span></td>

<td><span class="phpmaker"><a href="acessorios_carroslist.php?showmaster=1&id_estoque=<?php echo urlencode($x_Id_estoque); ?>">ACESS. </a></span></td>

</tr>

<?php

}

}

?>

</table>

</form>

<?php

}



// Close recordset and connection

phpmkr_free_result($rs);

phpmkr_db_close($conn);

?>

<form action="estoquelist.php" name="ewpagerform" id="ewpagerform">

<table>

<tr>

<td nowrap>

<?php

if ($nTotalRecs > 0) {

$rsEof = ($nTotalRecs < ($nStartRec + $nDisplayRecs));

$PrevStart = $nStartRec - $nDisplayRecs;

if ($PrevStart < 1) { $PrevStart = 1; }

$NextStart = $nStartRec + $nDisplayRecs;

if ($NextStart > $nTotalRecs) { $NextStart = $nStartRec ; }

$LastStart = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;

?>

<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker">Página&nbsp;</span></td>

<!--first page button-->

<?php if ($nStartRec == 1) { ?>

<td><img src="images/firstdisab.gif" alt="Primeiro" width="16" height="16" border="0"></td>

<?php } else { ?>

<td><a href="estoquelist.php?start=1"><img src="images/first.gif" alt="Primeiro" width="16" height="16" border="0"></a></td>

<?php } ?>

<!--previous page button-->

<?php if ($PrevStart == $nStartRec) { ?>

<td><img src="images/prevdisab.gif" alt="Anterior" width="16" height="16" border="0"></td>

<?php } else { ?>

<td><a href="estoquelist.php?start=<?php echo $PrevStart; ?>"><img src="images/prev.gif" alt="Anterior" width="16" height="16" border="0"></a></td>

<?php } ?>

<!--current page number-->

<td><input type="text" name="pageno" value="<?php echo intval(($nStartRec-1)/$nDisplayRecs+1); ?>" size="4"></td>

<!--next page button-->

<?php if ($NextStart == $nStartRec) { ?>

<td><img src="images/nextdisab.gif" alt="Próximo" width="16" height="16" border="0"></td>

<?php } else { ?>

<td><a href="estoquelist.php?start=<?php echo $NextStart; ?>"><img src="images/next.gif" alt="Próximo" width="16" height="16" border="0"></a></td>

<?php } ?>

<!--last page button-->

<?php if ($LastStart == $nStartRec) { ?>

<td><img src="images/lastdisab.gif" alt="Último" width="16" height="16" border="0"></td>

<?php } else { ?>

<td><a href="estoquelist.php?start=<?php echo $LastStart; ?>"><img src="images/last.gif" alt="Último" width="16" height="16" border="0"></a></td>

<?php } ?>

<td><span class="phpmaker">&nbsp;de <?php echo intval(($nTotalRecs-1)/$nDisplayRecs+1);?></span></td>

</tr></table>

<?php if ($nStartRec > $nTotalRecs) { $nStartRec = $nTotalRecs; }

$nStopRec = $nStartRec + $nDisplayRecs - 1;

$nRecCount = $nTotalRecs - 1;

if ($rsEof) { $nRecCount = $nTotalRecs; }

if ($nStopRec > $nRecCount) { $nStopRec = $nRecCount; } ?>

<span class="phpmaker">Registros <?php echo $nStartRec; ?> a <?php echo $nStopRec; ?> de <?php echo $nTotalRecs; ?></span>

<?php } else { ?>

<?php if ($sSrchWhere == "0=101") { ?>

<span class="phpmaker"></span>

<?php } else { ?>

<span class="phpmaker">Nenhum registro encontrado</span>

<?php } ?>

<?php } ?>

</td>

</tr>

</table>

</form>

<?php include ("footer.php") ?>

<?php



//-------------------------------------------------------------------------------

// Function SetUpMasterDetail

// - Set up Master Detail criteria based on querystring parameter key_m

// - Variables setup: sDbWhereMaster, Session("TblMasterkey"), sDbWhereDetail, Session(TblDetailWhere)



function SetUpMasterDetail()

{

global $sDbWhereMaster;

global $sDbWhereDetail;

global $sKeyMaster;

global $nStartRec;

global $x_marca;



// Get the keys for master table

if (strlen(@$_GET[ewTblShowMaster]) > 0) {



// Reset start record counter (new master key)

$nStartRec = 1;

$_SESSION[ewSessionTblStartRec] = $nStartRec;

$sDbWhereMaster = ewSqlMasterFilter;

$sDbWhereDetail = ewSqlDetailFilter;

$x_marca = (get_magic_quotes_gpc()) ? stripslashes(@$_GET["marca"]) : @$_GET["marca"]; // Load parameter from QueryString

if (is_numeric($x_marca)) {

$sDbWhereMaster = str_replace("@marca", AdjustSql($x_marca), $sDbWhereMaster); // Replace key value

$sDbWhereDetail = str_replace("@marca", AdjustSql($x_marca), $sDbWhereDetail); // Replace key value

$_SESSION[ewSessionTblMasterKey . "_marca"] = $x_marca; // Save master key Value

} else {

$sDbWhereMaster = "0=1";

$sDbWhereDetail = "0=1";

}

$_SESSION[ewSessionTblMasterWhere] = $sDbWhereMaster;

$_SESSION[ewSessionTblDetailWhere] = $sDbWhereDetail;

} else {

$sDbWhereMaster = @$_SESSION[ewSessionTblMasterWhere];

$sDbWhereDetail = @$_SESSION[ewSessionTblDetailWhere];

}

}



//-------------------------------------------------------------------------------

// Function BasicSearchSQL

// - Build WHERE clause for a keyword



function BasicSearchSQL($Keyword)

{

$sKeyword = (!get_magic_quotes_gpc()) ? addslashes($Keyword) : $Keyword;

$BasicSearchSQL = "";

$BasicSearchSQL.= "`Tipo` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`anuncio` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`cor` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`preço` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`km` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`placa` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`condicoes` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`combustivel` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`transmissao` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`descricao` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`oferta` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`exibir` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`avisado` LIKE '%" . $sKeyword . "%' OR ";

$BasicSearchSQL.= "`contato` LIKE '%" . $sKeyword . "%' OR ";

if (substr($BasicSearchSQL, -4) == " OR ") { $BasicSearchSQL = substr($BasicSearchSQL, 0, strlen($BasicSearchSQL)-4); }

return $BasicSearchSQL;

}



//-------------------------------------------------------------------------------

// Function SetUpBasicSearch

// - Set up Basic Search parameter based on form elements pSearch & pSearchType

// - Variables setup: sSrchBasic



function SetUpBasicSearch()

{

global $sSrchBasic, $psearch, $psearchtype;

if ($psearch <> "") {

if ($psearchtype <> "") {

while (strpos($psearch, " ") != false) {

$psearch = str_replace(" ", " ",$psearch);

}

$arKeyword = split(" ", trim($psearch));

foreach ($arKeyword as $sKeyword) {

$sSrchBasic .= "(" . BasicSearchSQL($sKeyword) . ") " . $psearchtype . " ";

}

} else {

$sSrchBasic = BasicSearchSQL($psearch);

}

}

if (substr($sSrchBasic, -4) == " OR ") { $sSrchBasic = substr($sSrchBasic, 0, strlen($sSrchBasic)-4); }

if (substr($sSrchBasic, -5) == " AND ") { $sSrchBasic = substr($sSrchBasic, 0, strlen($sSrchBasic)-5); }

if ($psearch <> "") {

$_SESSION[ewSessionTblBasicSrch] = $psearch;

$_SESSION[ewSessionTblBasicSrchType] = $psearchtype;

}

}



//-------------------------------------------------------------------------------

// Function ResetSearch

// - Clear all search parameters



function ResetSearch()

{



// Clear search where

$sSrchWhere = "";

$_SESSION[ewSessionTblSearchWhere] = $sSrchWhere;



// Clear advanced search parameters

$_SESSION[ewSessionTblAdvSrch . "_x_Tipo"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_anuncio"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_Id_estoque"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_id_plano"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_data_cadastro"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_data"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_id_membro"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_categoria"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_marcas"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_marca"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_ano"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_ano2"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_cor"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_preco"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_cidade"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_km"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_placa"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_condicoes"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_portas"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_combustivel"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_transmissao"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_descricao"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_oferta"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_exibir"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_avisado"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_entrada"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_qtd_parcelas"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_valor_parcelas"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_contato"] = "";

$_SESSION[ewSessionTblAdvSrch . "_x_acessos"] = "";

$_SESSION[ewSessionTblBasicSrch] = "";

$_SESSION[ewSessionTblBasicSrchType] = "";

}



//-------------------------------------------------------------------------------

// Function RestoreSearch

// - Restore all search parameters

//



function RestoreSearch()

{



// Restore advanced search settings

$GLOBALS["x_Tipo"] = @$_SESSION[ewSessionTblAdvSrch . "_x_Tipo"];

$GLOBALS["x_anuncio"] = @$_SESSION[ewSessionTblAdvSrch . "_x_anuncio"];

$GLOBALS["x_Id_estoque"] = @$_SESSION[ewSessionTblAdvSrch . "_x_Id_estoque"];

$GLOBALS["x_id_plano"] = @$_SESSION[ewSessionTblAdvSrch . "_x_id_plano"];

$GLOBALS["x_data_cadastro"] = @$_SESSION[ewSessionTblAdvSrch . "_x_data_cadastro"];

$GLOBALS["x_data"] = @$_SESSION[ewSessionTblAdvSrch . "_x_data"];

$GLOBALS["x_id_membro"] = @$_SESSION[ewSessionTblAdvSrch . "_x_id_membro"];

$GLOBALS["x_categoria"] = @$_SESSION[ewSessionTblAdvSrch . "_x_categoria"];

$GLOBALS["x_marcas"] = @$_SESSION[ewSessionTblAdvSrch . "_x_marcas"];

$GLOBALS["x_marca"] = @$_SESSION[ewSessionTblAdvSrch . "_x_marca"];

$GLOBALS["x_ano"] = @$_SESSION[ewSessionTblAdvSrch . "_x_ano"];

$GLOBALS["x_ano2"] = @$_SESSION[ewSessionTblAdvSrch . "_x_ano2"];

$GLOBALS["x_cor"] = @$_SESSION[ewSessionTblAdvSrch . "_x_cor"];

$GLOBALS["x_preco"] = @$_SESSION[ewSessionTblAdvSrch . "_x_preco"];

$GLOBALS["x_cidade"] = @$_SESSION[ewSessionTblAdvSrch . "_x_cidade"];

$GLOBALS["x_km"] = @$_SESSION[ewSessionTblAdvSrch . "_x_km"];

$GLOBALS["x_placa"] = @$_SESSION[ewSessionTblAdvSrch . "_x_placa"];

$GLOBALS["x_condicoes"] = @$_SESSION[ewSessionTblAdvSrch . "_x_condicoes"];

$GLOBALS["x_portas"] = @$_SESSION[ewSessionTblAdvSrch . "_x_portas"];

$GLOBALS["x_combustivel"] = @$_SESSION[ewSessionTblAdvSrch . "_x_combustivel"];

$GLOBALS["x_transmissao"] = @$_SESSION[ewSessionTblAdvSrch . "_x_transmissao"];

$GLOBALS["x_descricao"] = @$_SESSION[ewSessionTblAdvSrch . "_x_descricao"];

$GLOBALS["x_oferta"] = @$_SESSION[ewSessionTblAdvSrch . "_x_oferta"];

$GLOBALS["x_exibir"] = @$_SESSION[ewSessionTblAdvSrch . "_x_exibir"];

$GLOBALS["x_avisado"] = @$_SESSION[ewSessionTblAdvSrch . "_x_avisado"];

$GLOBALS["x_entrada"] = @$_SESSION[ewSessionTblAdvSrch . "_x_entrada"];

$GLOBALS["x_qtd_parcelas"] = @$_SESSION[ewSessionTblAdvSrch . "_x_qtd_parcelas"];

$GLOBALS["x_valor_parcelas"] = @$_SESSION[ewSessionTblAdvSrch . "_x_valor_parcelas"];

$GLOBALS["x_contato"] = @$_SESSION[ewSessionTblAdvSrch . "_x_contato"];

$GLOBALS["x_acessos"] = @$_SESSION[ewSessionTblAdvSrch . "_x_acessos"];

$GLOBALS["psearch"] = @$_SESSION[ewSessionTblBasicSrch];

$GLOBALS["psearchtype"] = @$_SESSION[ewSessionTblBasicSrchType];

}



//-------------------------------------------------------------------------------

// Function SetUpSortOrder

// - Set up Sort parameters based on Sort Links clicked

// - Variables setup: sOrderBy, Session(TblOrderBy), Session(Tbl_Field_Sort)



function SetUpSortOrder()

{

global $sOrderBy;

global $sDefaultOrderBy;



// Check for an Order parameter

if (strlen(@$_GET["order"]) > 0) {

$sOrder = @$_GET["order"];



// Field `anuncio`

if ($sOrder == "anuncio") {

$sSortField = "`anuncio`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_anuncio"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_anuncio"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_anuncio"] <> "") { @$_SESSION[ewSessionTblSort . "_x_anuncio"] = ""; }

}



// Field `Id_estoque`

if ($sOrder == "Id_estoque") {

$sSortField = "`Id_estoque`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_Id_estoque"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_Id_estoque"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_Id_estoque"] <> "") { @$_SESSION[ewSessionTblSort . "_x_Id_estoque"] = ""; }

}



// Field `id_plano`

if ($sOrder == "id_plano") {

$sSortField = "`id_plano`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_id_plano"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_id_plano"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_id_plano"] <> "") { @$_SESSION[ewSessionTblSort . "_x_id_plano"] = ""; }

}



// Field `data_cadastro`

if ($sOrder == "data_cadastro") {

$sSortField = "`data_cadastro`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_data_cadastro"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_data_cadastro"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_data_cadastro"] <> "") { @$_SESSION[ewSessionTblSort . "_x_data_cadastro"] = ""; }

}



// Field `data`

if ($sOrder == "data") {

$sSortField = "`data`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_data"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_data"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_data"] <> "") { @$_SESSION[ewSessionTblSort . "_x_data"] = ""; }

}



// Field `categoria`

if ($sOrder == "categoria") {

$sSortField = "`categoria`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_categoria"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_categoria"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_categoria"] <> "") { @$_SESSION[ewSessionTblSort . "_x_categoria"] = ""; }

}



// Field `marcas`

if ($sOrder == "marcas") {

$sSortField = "`marcas`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_marcas"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_marcas"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_marcas"] <> "") { @$_SESSION[ewSessionTblSort . "_x_marcas"] = ""; }

}



// Field `marca`

if ($sOrder == "marca") {

$sSortField = "`marca`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_marca"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_marca"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_marca"] <> "") { @$_SESSION[ewSessionTblSort . "_x_marca"] = ""; }

}



// Field `exibir`

if ($sOrder == "exibir") {

$sSortField = "`exibir`";

$sLastSort = @$_SESSION[ewSessionTblSort . "_x_exibir"];

$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";

$_SESSION[ewSessionTblSort . "_x_exibir"] = $sThisSort;

} else {

if (@$_SESSION[ewSessionTblSort . "_x_exibir"] <> "") { @$_SESSION[ewSessionTblSort . "_x_exibir"] = ""; }

}

$_SESSION[ewSessionTblOrderBy] = $sSortField . " " . $sThisSort;

$_SESSION[ewSessionTblStartRec] = 1;

}

$sOrderBy = @$_SESSION[ewSessionTblOrderBy];

if ($sOrderBy == "") {

if (ewSqlOrderBy <> "" && ewSqlOrderBySessions <> "") {

$sOrderBy = ewSqlOrderBy;

@$_SESSION[ewSessionTblOrderBy] = $sOrderBy;

$arOrderBy = explode(",", ewSqlOrderBySessions);

for($i=0; $i<count($arOrderBy); $i+=2) {

@$_SESSION[ewSessionTblSort . "_" . $arOrderBy[$i]] = $arOrderBy[$i+1];

}

}

}

}



//-------------------------------------------------------------------------------

// Function SetUpStartRec

//- Set up Starting Record parameters based on Pager Navigation

// - Variables setup: nStartRec



function SetUpStartRec()

{



// Check for a START parameter

global $nStartRec;

global $nDisplayRecs;

global $nTotalRecs;

if (strlen(@$_GET[ewTblStartRec]) > 0) {

$nStartRec = @$_GET[ewTblStartRec];

$_SESSION[ewSessionTblStartRec] = $nStartRec;

} elseif (strlen(@$_GET["pageno"]) > 0) {

$nPageNo = @$_GET["pageno"];

if (is_numeric($nPageNo)) {

$nStartRec = ($nPageNo-1)*$nDisplayRecs+1;

if ($nStartRec <= 0) {

$nStartRec = 1;

} elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {

$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;

}

$_SESSION[ewSessionTblStartRec] = $nStartRec;

} else {

$nStartRec = @$_SESSION[ewSessionTblStartRec];

}

} else {

$nStartRec = @$_SESSION[ewSessionTblStartRec];

}



// Check if correct start record counter

if (!(is_numeric($nStartRec)) || ($nStartRec == "")) { // Avoid invalid start record counter

$nStartRec = 1; // Reset start record counter

$_SESSION[ewSessionTblStartRec] = $nStartRec;

} elseif ($nStartRec > $nTotalRecs) { // Avoid starting record > total records

$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record

$_SESSION[ewSessionTblStartRec] = $nStartRec;

}

}



//-------------------------------------------------------------------------------

// Function ResetCmd

// - Clear list page parameters

// - RESET: reset search parameters

// - RESETALL: reset search & master/detail parameters

// - RESETSORT: reset sort parameters



function ResetCmd()

{



// Get Reset command

if (strlen(@$_GET["cmd"]) > 0) {

$sCmd = @$_GET["cmd"];

if (strtolower($sCmd) == "reset") { // Reset search criteria

ResetSearch();

} elseif (strtolower($sCmd) == "resetall") { // Reset search criteria and session vars

ResetSearch();

$_SESSION[ewSessionTblMasterWhere] = ""; // Clear master criteria

$sDbWhereMaster = "";

$_SESSION[ewSessionTblDetailWhere] = ""; // Clear detail criteria

$sDbWhereDetail = "";

$_SESSION[ewSessionTblMasterKey . "_marca"] = ""; // Clear master key value

} elseif (strtolower($sCmd) == "resetsort") { // Reset sort criteria

$sOrderBy = "";

$_SESSION[ewSessionTblOrderBy] = $sOrderBy;

if (@$_SESSION[ewSessionTblSort . "_x_anuncio"] <> "") { $_SESSION[ewSessionTblSort . "_x_anuncio"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_Id_estoque"] <> "") { $_SESSION[ewSessionTblSort . "_x_Id_estoque"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_id_plano"] <> "") { $_SESSION[ewSessionTblSort . "_x_id_plano"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_data_cadastro"] <> "") { $_SESSION[ewSessionTblSort . "_x_data_cadastro"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_data"] <> "") { $_SESSION[ewSessionTblSort . "_x_data"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_categoria"] <> "") { $_SESSION[ewSessionTblSort . "_x_categoria"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_marcas"] <> "") { $_SESSION[ewSessionTblSort . "_x_marcas"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_marca"] <> "") { $_SESSION[ewSessionTblSort . "_x_marca"] = ""; }

if (@$_SESSION[ewSessionTblSort . "_x_exibir"] <> "") { $_SESSION[ewSessionTblSort . "_x_exibir"] = ""; }

}



// Reset start position (Reset command)

$nStartRec = 1;

$_SESSION[ewSessionTblStartRec] = $nStartRec;

}

}

?>[/codebox]

Link to comment
Share on other sites

  • 0

Dentro do seu código tem a seguinte linha:

// echo $sSql . "<br>"; // Uncomment to show SQL for debugging

Retire o // antes do echo, para que na sua tela o comando SQL seja mostrado. Aí poste aí para a gente o comando.

Obs: O ESerra está correto. Ninguém tem tempo para ficar lendo um script enorme como esse (e resolvendo de graça as coisas). Aqui nós resolvemos dúvidas pontuais.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.5k
×
×
  • Create New...