Autor Tópico: Resolvido, CONFIRAM! Ordem dos anúncios - ajudem, please!!!  (Lida 480 vezes)

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Resolvido, CONFIRAM! Ordem dos anúncios - ajudem, please!!!
« em: Julho 14, 2010, 04:33:59 pm »
Possuo um site lucrebem.com.br que funciona como classificados online, infelizmente ainda faltam 3 coisas para serem feitas: Mudar a ordem que os anúncios são exibidos, opção para mudar senha, e opção para lemebrar da senha.

No momento, o mais importante, é a ordem dos anúncios, o site exibe primeiro os anúncios mais antigos, e depois vai para os mais novos, alguém saberia como mudar (na verdade, inverter a ordem)???????????????????????????????????????????????


O site está em php, utiliza bando de dados.


Obrigado



PS: Se precisarem do código php, por favor, me avisem.
« Última modificação: Julho 17, 2010, 05:03:22 pm por matheusgrafix »
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline Arkantos

  • Newbie
  • *
  • Mensagens: 24
  • Reputação: +0/-0
    • Ver Perfil
    • Webcenter
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #1 em: Julho 14, 2010, 05:24:57 pm »
Muito simples qualquer coisa como SELECT * FROM TABELA ORDER BY ID

Espero ter ajudado
Webcenter-Solutions
URL: www.webcenter-solutions.com

Offline Arkantos

  • Newbie
  • *
  • Mensagens: 24
  • Reputação: +0/-0
    • Ver Perfil
    • Webcenter
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #2 em: Julho 14, 2010, 05:26:33 pm »
DESC OU ASC esqueci-me disto! Sorry, procura no google que encontras montes de informação sobre isto
Webcenter-Solutions
URL: www.webcenter-solutions.com

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #3 em: Julho 14, 2010, 08:49:48 pm »
Tentei, ainda não consequi, repare que os últimos anúncios adicionados estão no final da página http://lucrebem.com.br


Tem dois arquivos que tem ASC, mudei pra DESC, e nao deu em nada, entao mudei pra ASC de novo, verifiquei que sao esses arquivos que pegam as tabelas, vou colar os dois codigo na linha abaixo:


Código: [Seleccione]
<?php



require_once 'path_cnfg.php';

require_once(
path_cnfg('pathToLibDir').'func_common.php'); 
require_once(
path_cnfg('pathToLibDir').'func_checkUser.php');
require_once(
path_cnfg('pathToLibDir').'func_tree.php');
require_once(
path_cnfg('pathToLibDir').'func_getResults.php');
require_once(
path_cnfg('pathToCnfgDir').'cnfg_vars.php');
require_once(
path_cnfg('pathToLibDir').'vars_gbl.php');

$cookie $HTTP_COOKIE_VARS['log_in_cookie'];

$content = array();

$myDB db_connect();

checkUser(''''); 

$content[] = 'doShow();';

// This line brings in the template file.
// If you want to use a different template file 
// simply change this line to require the template 
// file that you want to use.
require_once(path_cnfg('pathToTemplatesDir').cnfg('tmplt_showCat'));

db_disconnect($myDB);


# --- START FUNCTIONS ---

// ************* START FUNCTION doShow() *************

function doShow()
{
    GLOBAL 
$myDB$HTTP_GET_VARS  ;

    
$cat_id $HTTP_GET_VARS["cat_id"];

    if (
$cat_id)
    { 
        
$query 'SELECT cat_id,parent_id,cat_name FROM std_categories WHERE cat_id='.$cat_id;

        
$result mysql_query($query,$myDB);
        
$num_rows mysql_num_rows($result);

        
#echo '$num_rows = '.$num_rows.'<BR>';

        
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">
              <tr><td valign="top" width="100%">
              '
;

    
        
$path climb_tree($cat_id'showCat');
        
#echo '$path = '.$path.'<BR>';
        
$path_arr split("\!\@\#_SPLIT_\!\@\#"$path);
        for (
$i=0$i<count($path_arr); $i++)
        {   echo 
$path_arr[$i] ; 
            if (
$i count($path_arr)-2)
            {   echo 
'<FONT CLASS="subCat" COLOR="#FF0000"><B>&gt;&gt;</B></FONT>'
            }
        }
     
        echo 
'<BR><BR>';
        echo 
'</td></tr></table>';

        
$query 'SELECT cat_name,cat_id FROM std_categories 
                  WHERE parent_id='
.$cat_id.
                  ORDER BY cat_name ASC' 
;

        
$result mysql_query($query,$myDB);

        if (
mysql_num_rows($result) > )
        {   
display_cats_sub($result$cat_id);
        }
        else
        {   
getResults();
        }


    } 
// end if($cat_id)

// end function doShow()

// ************* END FUNCTION doShow() *************


// ************* START FUNCTION display_cats_sub() *************

function display_cats_sub($result$cat_id)
{
    GLOBAL 
$myDB;

    
$num_cols cnfg('subCatsCols');
    
$col_buffer_size cnfg('subCatsBufferCols');
    
$td_width cnfg('subCatsTdWidth');
    
$table_width cnfg('subCatsTableWidth');
    
$table_pad cnfg('subCatsTablePad');
    
$table_spc cnfg('subCatsTableSpace');
    
$centered_or_not cnfg('subCatsCenter');

    if (
$centered_or_not)
    {   echo 
'<CENTER>' 
    }

    echo 
'<table cellpadding="'.$table_pad.'" cellspacing="'.$table_spc.'" ';
    echo 
'border="0" width="'.$table_width.'">';

    
$countCols 1;
    
$num_cols $num_cols+($num_cols-1);

    for (
$i=0$i<mysql_num_rows($result); $i++  )
    { 
        if (
$countCols==
        {   echo 
'<tr>'."\n"
        }

        
$num_ads 0;

        if ( 
$countCols == )
        {   echo 
'<td valign=top width="'.cnfg('subCatsBufferCols').'">'."\n" 
            echo 
'<img src="'.cnfg('deDir').'/images/trans.gif" ';
            echo 
'border="0" width="50" height="1">'."\n";
            echo 
'</td>'."\n";

            
$i-- ; // no data used from $result array, so decrement the iterator.
        
}
        else
        {   
$row mysql_fetch_array($result) ;     
            
get_num_ads($row["cat_id"], true$num_ads); 


            echo 
'<td valign="top" width="'.$td_width.'">'."\n";
            echo 
'<a href="'.cnfg('deDir').'showCat.php?cat_id='.
                  
$row["cat_id"].'">'."\n" ;
            echo 
'<FONT CLASS="subCat">';
            echo 
$row['cat_name'];
            echo 
'</FONT>';
            echo 
'</a>&nbsp;';
            echo 
'<FONT CLASS="subCat">('.$num_ads.')</FONT>'."\n";
            echo 
'</td>'."\n";
        }

     
        if(
$countCols==$num_cols || $i==(mysql_num_rows($result)-1) )
        {   
$countCols=1
            echo 
'</tr>';
        }  
        else
        {   
$countCols++ ; 
        }

    } 
// end while

    
echo '</table>';

    if(
$centered_or_not)
    {   echo 
'</CENTER>' 
    }

// end function display_cats_sub()

// ************* END FUNCTION display_cats_sub() *************


?>


















E este





















Código: [Seleccione]
<?php



require_once 'path_cnfg.php';

require_once(
path_cnfg('pathToLibDir').'func_common.php'); 
require_once(
path_cnfg('pathToLibDir').'func_checkUser.php');
require_once(
path_cnfg('pathToLibDir').'func_tree.php');
require_once(
path_cnfg('pathToLibDir').'func_getResults.php');
require_once(
path_cnfg('pathToCnfgDir').'cnfg_vars.php');
require_once(
path_cnfg('pathToLibDir').'vars_gbl.php');

$cookie $HTTP_COOKIE_VARS['log_in_cookie'];

$content = array();

$myDB db_connect();

checkUser(''''); 

$content[] = 'doShow();';

// This line brings in the template file.
// If you want to use a different template file 
// simply change this line to require the template 
// file that you want to use.
content($content);

db_disconnect($myDB);


# --- START FUNCTIONS ---

// ************* START FUNCTION doShow() *************

function doShow()
{
    GLOBAL 
$myDB$HTTP_GET_VARS  ;

    
$cat_id $HTTP_GET_VARS["cat_id"];

    if (
$cat_id)
    { 
        
$query 'SELECT cat_id,parent_id,cat_name FROM std_categories WHERE cat_id='.$cat_id;

        
$result mysql_query($query,$myDB);
        
$num_rows mysql_num_rows($result);

        
#echo '$num_rows = '.$num_rows.'<BR>';

        
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">
              <tr><td valign="top" width="100%">
              '
;

    
        
$path climb_tree($cat_id'showCat');
        
#echo '$path = '.$path.'<BR>';
        
$path_arr split("\!\@\#_SPLIT_\!\@\#"$path);
        for (
$i=0$i<count($path_arr); $i++)
        {   echo 
$path_arr[$i] ; 
            if (
$i count($path_arr)-2)
            {   echo 
'<FONT CLASS="subCat" COLOR="#FF0000"><B>&gt;&gt;</B></FONT>'
            }
        }
     
        echo 
'<BR><BR>';
        echo 
'</td></tr></table>';

        
$query 'SELECT cat_name,cat_id FROM std_categories 
                  WHERE parent_id='
.$cat_id.
                  ORDER BY cat_name ASC' 
;

        
$result mysql_query($query,$myDB);

        if (
mysql_num_rows($result) > )
        {   
display_cats_sub($result$cat_id);
        }
        else
        {   
getResults();
        }


    } 
// end if($cat_id)

// end function doShow()

// ************* END FUNCTION doShow() *************


// ************* START FUNCTION display_cats_sub() *************

function display_cats_sub($result$cat_id)
{
    GLOBAL 
$myDB;

    
$num_cols cnfg('subCatsCols');
    
$col_buffer_size cnfg('subCatsBufferCols');
    
$td_width cnfg('subCatsTdWidth');
    
$table_width cnfg('subCatsTableWidth');
    
$table_pad cnfg('subCatsTablePad');
    
$table_spc cnfg('subCatsTableSpace');
    
$centered_or_not cnfg('subCatsCenter');

    if (
$centered_or_not)
    {   echo 
'<CENTER>' 
    }

    echo 
'<table cellpadding="'.$table_pad.'" cellspacing="'.$table_spc.'" ';
    echo 
'border="0" width="'.$table_width.'">';

    
$countCols 1;
    
$num_cols $num_cols+($num_cols-1);

    for (
$i=0$i<mysql_num_rows($result); $i++  )
    { 
        if (
$countCols==
        {   echo 
'<tr>'."\n"
        }

        
$num_ads 0;

        if ( 
$countCols == )
        {   echo 
'<td valign=top width="'.cnfg('subCatsBufferCols').'">'."\n" 
            echo 
'<img src="'.cnfg('deDir').'/images/trans.gif" ';
            echo 
'border="0" width="50" height="1">'."\n";
            echo 
'</td>'."\n";

            
$i-- ; // no data used from $result array, so decrement the iterator.
        
}
        else
        {   
$row mysql_fetch_array($result) ;     
            
get_num_ads($row["cat_id"], true$num_ads); 


            echo 
'<td valign="top" width="'.$td_width.'">'."\n";
            echo 
'<a href="'.cnfg('deDir').'showCat.php?cat_id='.
                  
$row["cat_id"].'">'."\n" ;
            echo 
'<FONT CLASS="subCat">';
            echo 
$row['cat_name'];
            echo 
'</FONT>';
            echo 
'</a>&nbsp;';
            echo 
'<FONT CLASS="subCat">('.$num_ads.')</FONT>'."\n";
            echo 
'</td>'."\n";
        }

     
        if(
$countCols==$num_cols || $i==(mysql_num_rows($result)-1) )
        {   
$countCols=1
            echo 
'</tr>';
        }  
        else
        {   
$countCols++ ; 
        }

    } 
// end while

    
echo '</table>';

    if(
$centered_or_not)
    {   echo 
'</CENTER>' 
    }

// end function display_cats_sub()

// ************* END FUNCTION display_cats_sub() *************


?>




Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline Arkantos

  • Newbie
  • *
  • Mensagens: 24
  • Reputação: +0/-0
    • Ver Perfil
    • Webcenter
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #4 em: Julho 14, 2010, 10:28:43 pm »
Para isso funcionar nas melhores condições devias ordenar de forma ascendente ou descendente um campo numérico, porque tu estás a ordenar por nome da categoria, certamente que cada anuncio publicado tem um ID, por isso ordena por ID de anúncio que já deve resolver esse problema!
Webcenter-Solutions
URL: www.webcenter-solutions.com

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #5 em: Julho 14, 2010, 11:13:48 pm »
Ora pois, como faço isso?  :rolleyes:
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #6 em: Julho 15, 2010, 01:17:13 am »
Alguém????
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #7 em: Julho 15, 2010, 01:34:16 am »
Não tenho certeza, mas parece que o sistema não está organizando nada, só as categorias, e o que precisa ser organizado, são os itens, de acordo com minhas observações, o sistema está carregando tudo o que tem na categoria utilizando apenas a funçaõ de chamar a categoria,  preciso que, além de chamar a categoria, ele também ordene pela id dos itens. Abri o banco de dados e verifiquei que os itens estao em "std_items", e dentro dessa tabela estão as tabelas das subcategorias (as que precisam ser organizadas) o nome é "item_id", é "item_id" que numera as subcategorias, e na ordem, de cima para baixo, ele começa desde menor número, e então desce. É por isso que no site, está mostrando primeiro, os anúncios mais antigos, por que eles são os que possuem a menor numeração, e a menor númeração vem primeiro, de cima para baixo.


O que faço para inverter essa ordem?
« Última modificação: Julho 15, 2010, 01:37:02 am por matheusgrafix »
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline Arkantos

  • Newbie
  • *
  • Mensagens: 24
  • Reputação: +0/-0
    • Ver Perfil
    • Webcenter
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #8 em: Julho 15, 2010, 09:23:01 am »
 $query = 'SELECT cat_name,cat_id FROM std_categories
                  WHERE parent_id='.$cat_id.'
                  ORDER BY item_id DESC' ;

Não sei se a tabela que contem os anuncios é essa, mas experimenta assim
Webcenter-Solutions
URL: www.webcenter-solutions.com

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #9 em: Julho 15, 2010, 03:38:48 pm »
A tabela se chama std_items, e dentro dela tem essa parte items_id
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline Arkantos

  • Newbie
  • *
  • Mensagens: 24
  • Reputação: +0/-0
    • Ver Perfil
    • Webcenter
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #10 em: Julho 15, 2010, 04:11:10 pm »
$query = 'SELECT cat_name,cat_id FROM std_items
                  WHERE parent_id='.$cat_id.'
                  ORDER BY items_id DESC' ;

Então é isto...  :afro:
Webcenter-Solutions
URL: www.webcenter-solutions.com

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #11 em: Julho 16, 2010, 12:58:51 am »
hun, nao deu, deu erro. Tem como me ajudar pelo msn?

matheuswebdesigner@hotmail.com


Só preciso disso, depois eu vou divulgar o site aqui na cidade.
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #12 em: Julho 17, 2010, 06:22:18 am »
Não é aquele arquivo que faz isso, ele apenas pega a categoria.

ME lembrei disso agora, o arquivo que carrega as subcategorias é este:

Código: [Seleccione]
<?php

// ************* START function get_searchable_cats() *************

function get_searchable_cats($cat_id, &$cats_arr)
{
    GLOBAL 
$myDB
  
    
$query "SELECT cat_id, cat_name FROM std_categories WHERE 
              top_parent_id=$cat_id" 
;
    
$result mysql_query($query);

    while (
$row mysql_fetch_array($result) )
    {   
$query2 'SELECT * FROM std_categories 
                   WHERE parent_id='
.$row["cat_id"];
        
$result2 mysql_query($query2);
        if (
mysql_num_rows($result2) == )
        {   
$cats_arr[] = $row["cat_id"];
        }
    }

// end function get_searchable_cats()

// ************* END function get_searchable_cats() *************



// ************* START FUNCTION getResults() *************

function getResults()
{
    GLOBAL 
$myDB$HTTP_GET_VARS$HTTP_POST_VARS  ;

    if (isset(
$HTTP_POST_VARS["search"]) )
    {   
$search $HTTP_POST_VARS["search"] ;
    }
    elseif(isset(
$HTTP_GET_VARS["search"]) )
    {   
$search $HTTP_GET_VARS["search"] ; ; 
    }


    
$category   $HTTP_POST_VARS["category"];
  
    
$doSearch  $HTTP_GET_VARS["doSearch"];
    
$cat_id    $HTTP_GET_VARS["cat_id"];
    
$offset    $HTTP_GET_VARS["offset"];


    
$bgcolor cnfg('viewAdsRowColor1');
    
$topRow true;
    
$searchOrShowCat '';

    if (!
$offset
    {   
$offset 
    }


    
$expTime time()-(cnfg('expireAdsDays')*86400);

    if (
$doSearch
    {   
$cats_arr = array();
        if (isset(
$category) && $category != 'none')
        {   
/* get_searchable_cats takes a reference 
             * to $cats_arr and loads it up.
             */
            
get_searchable_cats($category$cats_arr) ; 
        }
        
        
$query '
           SELECT 
           std_items.item_id as item_id,
           std_items.cat_id as cat_id,
           std_items.title as title,
           std_items.the_desc as the_desc,
           std_items.image_exists as image_exists,
           std_categories.cat_id as cat_id,
           std_categories.cat_name as cat_name
           FROM std_items,std_categories WHERE 
           (std_items.the_desc LIKE "%'
.$search.'%" OR 
           std_items.title LIKE "%'
.$search.'%")
           AND std_items.date_time>'
.$expTime.'
           AND std_items.cat_id=std_categories.cat_id'
;
       
        if (
count($cats_arr) > )
        {   
$query .= ' AND  (';
            for (
$i=0$i<count($cats_arr); $i++)
            {   
$query .= 'std_items.cat_id='.$cats_arr[$i] ;
                if (
$i != count($cats_arr)-)
                {   
$query .= ' OR ' 
                }
            }
            
$query .= ')';
        }
 
        
$searchOrShowCat 'search.php';
    }
    else
    {   
$query 'SELECT 
            std_items.item_id as item_id,
            std_items.cat_id as cat_id,
            std_items.title as title,
            std_items.the_desc as the_desc,
            std_items.image_exists as image_exists,
            std_categories.cat_id as cat_id,
            std_categories.cat_name as cat_name
            FROM std_items,std_categories 
            WHERE std_items.date_time>'
.$expTime.
        AND std_items.cat_id='
.$cat_id.'
            AND std_items.cat_id=std_categories.cat_id'

;

        
$searchOrShowCat 'showCat.php';
    $doSearch 0;
    }


    
$query .= ' LIMIT '.$offset.','."21" ;

    
#echo '$query = '.$query.'<BR>';

    
if ($offset != 0)
    {   
$offset += 20
    }


    
$result mysql_query($query,$myDB);
    if (!
$result)
    {   echo 
mysql_error(); 
    }

    
$num_rows mysql_num_rows($result);


    echo 
"<CENTER>\n";

    if (
$num_rows >0)
    { 
        
?>


        <table cellpadding="0" cellspacing="0" border="0" width="<?php echo  cnfg('rowsOfAdsTableWidth'?>">
        <tr>
        <td width="10%" align="left">

        <?php
     
        
if ( ($offset && $offset != 0) && ($offset != 10) )
        {
            echo 
'
                <a href="'
.cnfg('deDir').$searchOrShowCat.
                
'?doSearch='.$doSearch.'&search='.urlencode($search).'&offset=';
            echo 
$offset-40;
            echo 
"&cat_id=$cat_id";
            echo 
'"><font color="#FF0000"> < Página anterior</font></a>
              </td>'
;
            echo 
"\n";
        } 
        else
        {   echo 
'&nbsp;
              </td>'
;
            echo 
"\n";
        }

        
?>


        <td width="80%">
        <CENTER>
        <FONT CLASS="subCat">

        <?php
        
echo 'Resultados, desde os anúncios mais antigos.<br>';
        if (
$offset==0)
        {   echo (
$offset+1).'-'.($offset+20);
        }
        else
        {   echo ((
$offset-20)+1).'-'.$offset;
        }

        
?>


        &nbsp;&nbsp;
        </FONT></CENTER>
        </td>


        <?php

        
if($num_rows==21)
        {   echo 
'
              <td align="right" width="10%">
              <a href="'
.cnfg('deDir').$searchOrShowCat.'?doSearch='.$doSearch.'&search='
              
.urlencode($search).'&offset=';

            if (
$offset==0)
            {   echo 
$offset+20
            }
            else
            {   echo 
$offset
            } 

            echo 
"&cat_id=$cat_id";
            echo 
'"><font color="#FF0000">Próxima página > </font></a>
                 </td>
                  '

        }
        else
        {   
?>

            <td valign="right" width="10%">&nbsp;
           
            </td>
            <?php
        
}
  
        
?>

        </tr>
        </table>
     

        <table cellpadding="4" cellspacing="0" border="0" width="<?php echo  cnfg('rowsOfAdsTableWidth'?>">
        <tr>
        <td bgcolor="<?php echo $bgcolor ?>">
        <FONT COLOR="#000000" FACE="Tahoma">
        <CENTER>
        <B>Imagem</B>
        </CENTER>
        </FONT>
        </td>
        <td bgcolor="<?php echo $bgcolor ?>">
        <FONT COLOR="#000000" FACE="Tahoma">
        <CENTER>
        <B>Título</B>
        </CENTER>
        </FONT>
        </td>
        <td bgcolor="<?php echo $bgcolor ?>">
        <FONT COLOR="#000000" FACE="Tahoma">
        <CENTER>
        <B>Descrição</B>
        </CENTER>
        </FONT>
        </td>
        <td bgcolor="<?php echo $bgcolor ?>">
        <FONT COLOR="#000000" FACE="Tahoma">
        <CENTER>
        <B>Categoria</B>
        </CENTER>
        </FONT>
        </td>
        <td bgcolor="<?php echo $bgcolor ?>">&nbsp;
       
        </td>
        </tr>

        <?php 

        
if ($bgcolor == cnfg('viewAdsRowColor1') )
        {   
$bgcolor=cnfg('viewAdsRowColor2') ; 
        }
        else
        {   
$bgcolor cnfg('viewAdsRowColor1') ; 
        }

        
$count_to;
        if (
$num_rows>20)
        {   
$count_to 20
        }
        else
        {   
$count_to $num_rows
        }

        for (
$i=0$i<$count_to$i++)
        {   
$row mysql_fetch_array($result) ;

            
?>

            <tr>
            <td bgcolor="<?php echo $bgcolor?>">

            <?php
            
if ($row['image_exists'] && $row['image_exists'] == 'true')
            {   
?>


                <CENTER>
                <img src="<?php echo cnfg('deDir'?>images/pic_yes.gif" border="0" width="64" height="64">
                </CENTER>

                <?php
            
}
            elseif(!
$row['image_exists'] || $row['image_exists'] != 'true')
            {   
?>

                <CENTER>
                <img src="<?php echo cnfg('deDir'?>images/pic_no.gif" border="0" width="64" height="64">
                </CENTER> 

                <?php
            
}


            
?>


            </td>
            <td bgcolor="<?php echo $bgcolor ?>">

            <?php

            
if (strlen(stripslashes(strip_tags($row['title']))) > 14 )
            {   echo 
substr(stripslashes(strip_tags($row['title'])), 0,37),'....'
            }
            else
            {   echo 
stripslashes(strip_tags($row['title'])); 
            }

            
?>


            </td>
            <td bgcolor="<?php echo $bgcolor ?>">
         
            <?php

            $row
['the_desc'] = stripslashes(strip_tags($row['the_desc']));

            if (
strlen(stripslashes(strip_tags($row['the_desc']))) > 14 )
            {   echo 
substr(stripslashes(strip_tags($row['the_desc'])),0,80).'....'
            }
            else
            {   echo 
stripslashes(strip_tags($row['the_desc'])); 
            }
        
            echo 
'
                </td>
                <td bgcolor="'
.$bgcolor.'">'
                
.$row['cat_name'].
                
'</td>
                <td bgcolor="'
.$bgcolor.'"><a href="details.php?';
            if (
$doSearch)
            {   echo 
'doSearch=true';
            }

            if (
$row['cat_id'])
            {   echo 
'&cat_id='.$row['cat_id']; 
            }
            else
            {   echo 
'&cat_id='.$cat_id
            }

            echo 
'&item_id='.$row['item_id'].'&offset=';

            if (isset(
$offset) && $offset>0)
            {   echo 
$offset-20
            }
            else
            {   echo 
$offset;
            }


            echo 
'">';

            
?>


            <FONT FACE="Tahoma" STYLE="font-size:13pt; font-color:#ff0000;">
            Detalhes
            </FONT>
            </a>
            </td>
            </tr>
         
            <?php 

            
if ($bgcolor == cnfg('viewAdsRowColor1') )
            {   
$bgcolor=cnfg('viewAdsRowColor2'); 
            }
            else
            {   
$bgcolor cnfg('viewAdsRowColor1') ; 
            }

        } 
// end while

        
?>


     
        </td>
        </tr>
        </table>


        <table cellpadding="0" cellspacing="0" border="0" width="80%">
        <tr>
        <td align="left" width="20%"> 
     
        <?php

        
if ( ($offset && $offset != 0) && ($offset != 10) )
        {   echo 
'
                <a href="'
.cnfg('deDir').$searchOrShowCat.
                
'?doSearch='.$doSearch.'&search='.urlencode($search).'&offset=';
            echo 
$offset-40;
            echo 
"&cat_id=$cat_id";
            echo 
'"><font color="#FF0000"> < Página anterior</font></a>
              </td>'
;
            echo 
"\n";
        } 
        else
        {   echo 
'&nbsp;';
        }

        
?>

     
        </td>

        <td valign="top" width="60%">&nbsp;
       
        </td>
     
        <?php 

        
if ($num_rows==21)
        {   echo 
'
             <td align="right" width="20%">
             <a href="'
.cnfg('deDir').$searchOrShowCat.'?doSearch='.$doSearch.'&search='
             
.urlencode($search).'&offset=';

            if (
$offset==0)
            {   echo 
$offset+20
            }
            else
            {   echo 
$offset
            } 

            echo 
"&cat_id=$cat_id";
            echo 
'"><font color="#FF0000">Próxima página > </font></a>'
        }

        
?>

        </td>
        </tr>
        </table>

     

    <?php
    
// end if($num_rows >0){
    
else
    {   if (
$doSearch)
        {   echo 
'
              <table><tr><td valign="top">
              <BR>
              Lamento, nenhum resultado.<BR>
             
              </td></tr></table>'
;
        }
        else
        {   echo 
'
              <table><tr><td valign="top">
              <BR>
              Não há itens nesta categoria.<BR>
              <a href="javascript: onClick=history.go(-1);">
              << Volar
              </a>
              </td></tr></table>'
;
        }
    }

    echo 
"</CENTER>\n";

// end function getResults()


// ************** END FUNCTION getResults() *************

?>






Ainda estou aprendendo php, mas andei estudando esse arquivo, nao tenho certeza, mas deve ser nessa parte onde se insere o comando para organizar as subcategorias:



$query = 'SELECT
            std_items.item_id as item_id,
            std_items.cat_id as cat_id,
            std_items.title as title,
            std_items.the_desc as the_desc,
            std_items.image_exists as image_exists,
            std_categories.cat_id as cat_id,
            std_categories.cat_name as cat_name
            FROM std_items,std_categories
            WHERE std_items.date_time>'.$expTime.'
           AND std_items.cat_id='.$cat_id.'
            AND std_items.cat_id=std_categories.cat_id'
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.

Offline matheusgrafix

  • Global Moderator
  • Newbie
  • *****
  • Mensagens: 43
  • Reputação: +0/-0
    • Ver Perfil
Re:Ordem dos anúncios - ajudem, please!!!
« Responder #13 em: Julho 17, 2010, 05:02:30 pm »
Resolvi o problema:
Código: [Seleccione]
$query = '
           SELECT
           std_items.item_id as item_id,
           std_items.cat_id as cat_id,
           std_items.title as title,
           std_items.the_desc as the_desc,
           std_items.image_exists as image_exists,
           std_categories.cat_id as cat_id,
           std_categories.cat_name as cat_name
           FROM std_items,std_categories WHERE
           (std_items.the_desc LIKE "%'.$search.'%" OR
           std_items.title LIKE "%'.$search.'%")


   
           AND std_items.date_time>'.$expTime.'
           AND std_items.cat_id=std_categories.cat_id
   
   ORDER BY std_items.item_id DESC
   
   
   ';


Inseri ORDER BY std_items.item_id DESC no final, antes do ponto e virgula, e da aspa


Era tão simplessssssssssssss, meu Deus. Obrigado a todos, pela ajuda.
Você que tem um site, seja um blog, fórum, portal, etc., faça parte da nossa Rede social de webmasters. Aqui você poderá divulgar seu site gratuitamente e também poderá conhecer outras pessoas.