Show latest itens added, instead of oldest

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • matheussousuke
    New Member
    • Sep 2009
    • 249

    Show latest itens added, instead of oldest

    Hi, I'm tring to order the subcategories of my website, but I'm not getting any sucess, tried put desc instead of asc, nothing worked, as you can see in the URL below, it is ordering from back to front, and it should from front to back, I mean, latest added itens should come first, and in the first page, but the system does the oposite, it show the oldest intens first, take a look (It is in portuguese, to see each item you can click on "Detalhes", then, after going to the other page, take a look at the date that is "Publicado em:", date format is "DD/MM/YYYY":







    The code responsible for it is this one:


    Code:
    <?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) > 0 )
            {   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==1 ) 
            {   echo '<tr>'."\n"; 
            }
    
            $num_ads = 0;
    
            if ( $countCols % 2 == 0 )
            {   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() *************
    
    
    ?>






    PS: I tried altering almost every part, there are some parts that are responsible for the categories, and others that I don't understand intirely, the system works with categories, and subcategories, and I guess it also works with itens.
  • matheussousuke
    New Member
    • Sep 2009
    • 249

    #2
    So sorry

    I'm sorry, this is the correct code:
    Code:
    <?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) == 0 )
            {   $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 = 0 ; 
        }
    
    
        $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) > 0 )
            {   $query .= ' AND  (';
                for ($i=0; $i<count($cats_arr); $i++)
                {   $query .= 'std_items.cat_id='.$cats_arr[$i] ;
                    if ($i != count($cats_arr)-1 )
                    {   $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') ?>http://bytes.com/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') ?>http://bytes.com/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() *************
    
    ?>












    And the parts that call for the itens are these:



    Code:
      $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) > 0 )
            {   $query .= ' AND  (';
                for ($i=0; $i<count($cats_arr); $i++)
                {   $query .= 'std_items.cat_id='.$cats_arr[$i] ;
                    if ($i != count($cats_arr)-1 )
                    {   $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;
        }






    I'm trying here, but getting no results, I just need to make the system order the displayied items, does anyone has any idea?


    Just remembering, currently they are being showed from oldest to newest, oldest comes first, in the top of the page, and I need the oposite.

    This website is ery important, it helps a lot of people around here to find jobs, please, help =/

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      I’d try the ORDER BY clause on the SQL.

      Comment

      • matheussousuke
        New Member
        • Sep 2009
        • 249

        #4
        Originally posted by Dormilich
        I’d try the ORDER BY clause on the SQL.
        You mean inside the db on phpmyadmin?

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          inside the SQL string

          Comment

          • matheussousuke
            New Member
            • Sep 2009
            • 249

            #6
            I did this
            Code:
               $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.' 
            			
            			ORDER BY item_id DESC
            			
                        AND std_items.cat_id='.$cat_id.'
                        AND std_items.cat_id=std_categories.cat_id'		
            			;

            and got this error



            You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND std_items.cat_i d=19 AND std_items.cat_i d=std_categorie s.cat_id L' at line 15
            Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/lucrebem/public_html/lib/func_getResults .php on line 139

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              ORDER BY std_items.item_ id DESC

              don't forget to specify the table you’re using

              Comment

              • matheussousuke
                New Member
                • Sep 2009
                • 249

                #8
                Originally posted by Dormilich
                ORDER BY std_items.item_ id DESC

                don't forget to specify the table you’re using
                I did this
                Code:
                 {   $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.' 
                				
                				ORDER BY std_items.item_id DESC
                			
                			AND std_items.cat_id='.$cat_id.'
                            AND std_items.cat_id=std_categories.cat_id'
                			
                		
                							
                			;


                And got this error, I guess it's the same one as the other:

                You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND std_items.cat_i d=19 AND std_items.cat_i d=std_categorie s.cat_id L' at line 15
                Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/lucrebem/public_html/lib/func_getResults .php on line 142

                Comment

                • zorgi
                  Recognized Expert Contributor
                  • Mar 2008
                  • 431

                  #9
                  because you specified: std_items.item_ id as item_id
                  you should be able to use
                  ORDER BY std_items.item_ id DESC
                  or
                  ORDER BY item_id DESC.
                  Just stick it at the end of your sql command and not in the middle of your where clause

                  Comment

                  • matheussousuke
                    New Member
                    • Sep 2009
                    • 249

                    #10
                    I did this:
                    Code:
                       {   $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.' 
                    				
                    				ORDER BY std_items.item_id DESC
                    			
                    			AND std_items.cat_id='.$cat_id.'
                                AND std_items.cat_id=std_categories.cat_id'





                    Got the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM std_items,std_c ategories WHERE std_items.date_ time>-8.63999998' at line 15
                    Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/lucrebem/public_html/lib/func_getResults .php on line 142






                    And did this:
                    Code:
                      {   $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
                    			
                    
                    ORDER BY item_id DESC
                    
                    
                    		    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'

                    And got this error:

                    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM std_items,std_c ategories WHERE std_items.date_ time>-8.63999998' at line 10
                    Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/lucrebem/public_html/lib/func_getResults .php on line 142

                    Comment

                    • matheussousuke
                      New Member
                      • Sep 2009
                      • 249

                      #11
                      Originally posted by zorgi
                      You used

                      Code:
                      std_items.item_id as item_id
                      so you should be able to use

                      Code:
                      ORDER BY item_id DESC
                      just sick it at the end of your sql command not in the middle of your where clause
                      You mean I should exchange

                      Code:
                      # std_items.item_id as item_id
                      for

                      Code:
                      ORDER BY item_id DESC

                      ??

                      Comment

                      • matheussousuke
                        New Member
                        • Sep 2009
                        • 249

                        #12
                        Yes, I understand now, I have std_items.item_ id as item_id, and cause that, I'm able to use the command ORDER BY item_id DESC in the code, but as you can see, I did it, and did not work, and I also put the code before the ";", like this
                        Code:
                          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'
                        			
                        		    ORDER BY std_items.item_id DESC
                        							
                        			;

                        Comment

                        • zorgi
                          Recognized Expert Contributor
                          • Mar 2008
                          • 431

                          #13
                          You placed ORDER BY std_items.item_ id DESC outside your quotation marks ''

                          Comment

                          • matheussousuke
                            New Member
                            • Sep 2009
                            • 249

                            #14
                            hahahahahahahah aha


                            I did it, I did it, I did it, I'm crying of so happy.


                            Man, you came from heavennnnnnnnnn nnnnnnnnn


                            Thank youuuuuuuuuuuuu uuuuuuuuuuuuuuu uuuuuu


                            omg


                            I will faint if I keep like that



                            holy jesusssss


                            Now everyone is going to be able to see the latest jobs vacancies!!!!!!

                            Comment

                            • matheussousuke
                              New Member
                              • Sep 2009
                              • 249

                              #15
                              And I'd like to thank Dormilich too, he always help me when I post somthing here. Thx a lot, you guys are amazing

                              Comment

                              Working...