iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-17-2008, 01:15 PM
WebProWorld New Member
 
Join Date: Apr 2008
Posts: 1
Panta_Rei RepRank 0
Default Sort Table from Header

Hi to everybody.
I've a little problem....
I've this function:
PHP Code:
 
Function VisualizzaTabellaFooter($elencotabelle,$criterioricerca,$testodescrizione){ 
INCLUDE(
'config.php'); 
################################### 
//Function which visualizes the data contained in the table listini. They come visualizes to you in 
//one table that has lines of alternated color, click heading in order to sorting
############################################################# 
$connessione mysql_connect($db_host$db_user,$db_password) or die("Connessione fallita !"); 
@
mysql_select_db($db_name) or die("Selezione Database fallita !"); 
 
$testodescrizione=$_GET['testodescrizione']; 
$elencotabelle=$_GET['elencotabelle']; 
 
if (isset(
$_GET['field'])) { 
$campo $_GET['field'] == "descrizione" "descrizione" "Codice_articolo" 
} else { 
$campo "Costruttore"

if (isset(
$_GET['sort'])) { 
$verso $_GET['sort'] == "desc" "DESC" "ASC"
} else { 
$verso "ASC"

 
if ((
$elencotabelle=="listini" and  $testodescrizione="")or ($elencotabelle=="costruttori" or $elencotabelle=="categorie")){ 
          
//print whole listini table
 
$sql="SELECT * from listini order by {$campo} {$verso}  "
 
$risultato_query=mysql_query($sql,$connessione)or die ("query 1 fallita"); 
                             
                            } 
 
else{   
 
    
// print listini table whit FILTER based on WHERE condition
     
    
$word=trim($_GET['testodescrizione']); 
 
    
$sql1="SELECT * from listini where Codice_articolo like \"%$word%\"   order by {$campo} {$verso} 
"

    
$risultato_query=mysql_query($sql1,$connessione)or ("Query sbagliata " .mysql_error()); 
     
// controlla il risultato della query attraverso la funzione mysql_query 

 
$res_count=mysql_num_rows($risultato_query); 
// numero totale di records 
 
$verso = ($verso == "ASC") ? "desc" "asc"
 
  echo 
"<table width=\"747\" border=\"1\"> 
 <tr> 
   <td width=\"118\"class=\"intestazione\"width=\"223\"><a href='index.php?field=Costruttore&sort={$verso}'>Costruttore 
   </a></td> 
 
   <td width=\"164\" class=\"intestazione\"width=\"223\"><a href='index.php?field=Codice_articolo&sort={$verso}'>Codice_articolo</a></td> 
 
   <td width=\"149\" class=\"intestazione\"width=\"223\"><a href='index.php?field=descrizione&sort={$verso}'>descrizione</a></td> 
 
   <td width=\"141\"class=\"intestazione\"width=\"223\"><a href='index.php?field=listino&sort={$verso}'>listino</td> 
 
   <td width=\"141\"class=\"intestazione\"width=\"223\"><a href='index.php?field=Codice Barcode&sort={$verso}'>Codice Barcode</td> 
 
 </tr> 
</table>"

     echo
" <div id=\"Layer1\"  style=\" width:747px; height:115px; overflow: auto;\"> "
$class ''
 
while(
$riga=mysql_fetch_array($risultato_query)){ 
      
              
$Costruttore=$riga["Costruttore"]; 
             
$Codice_articolo=$riga["Codice_articolo"]; 
             
$descrizione=$riga["descrizione"]; 
              
$listino=$riga["listino"]; 
              
$barcode=$riga["codice_barcode"]; 
              
             
$class $class == 'colore1' 'colore2' 'colore1'
          
echo 
"<table width=\"747\" border=\"1\">"
             echo
" <tr class= \"$class\"> "
 
    echo
" <td  width=\"118\" class= \"$class\" >$Costruttore </td>"
    echo
"<td    width=\"164\" >$Codice_articolo</td>"
     echo
"<td    width=\"149\" >$descrizione</td>"
     echo
"<td    width=\"141\" >$listino</td>"
     echo
"<td    width=\"141\" >$barcode</td>"
    echo
"</tr>"
         } 
         echo
"</table>"
       echo
"</div>"
echo
"</td>"
  echo
" </tr>"
echo
"</body>"
echo
"</html>"

The function is OK when it is in the first if. That is Press all the table ' listini' and making click on the columns ALL TABLE SORT ITSSELF, on that field. When instead we are in the else, the FILTER works good with the WHERE condition, but MAKING CLICK On the COLUMNS, GIVES BACK to ALL the RECORDS to ME Of the TABLE, INDIFFERENTLY, WITHOUT FILTER. How I can arrange it? Thanks!
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a-z rbeck Database Discussion Forum 0 01-20-2008 08:51 AM
Table Align to table sysop9999 Graphics & Design Discussion Forum 3 11-10-2005 11:00 AM
'Sort by views' 'sort by replies' options AshleyKeane WebProWorld: Guidelines/Announcements/Suggestions 0 02-19-2005 04:44 PM
Voters Sort It Out Here Clicken The Castle Breakroom (General: Any Topic) 90 11-03-2004 11:13 PM


All times are GMT -4. The time now is 07:34 AM.



Search Engine Optimization by vBSEO 3.3.0