Visualizzazione dei risultati da 1 a 10 su 10
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805

    funzioni che non ricevono le variabili.

    salve ragazzi ancora una volta apro un thead di richiesta di aiuto , vi spiego io ho due funzioni , da una estraggo gli utenti e va benissimo e dallaltra dovrei passare le variabili definite soltanto che quando inserisco nella query degli user il limit e le variabili definite nell altra funzione mi da un errore che sarebbe questo
    codice:
    Manage Staff - Total:2 
     Nome username gruppo Actions 
    Error 1064 : 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 '' at line 1
    questa e la funzione degli user : le variabili sono dopo il limit $per_page $item
    Codice PHP:
    function GetStaff()
    {
      global 
    $dbcore;
      global 
    $settings ;
      global 
    $per_page,$item ;
      
    $query "select t. *  , gs. id_groups ,gs. nome_group from tech t  left join grouptech gs  on  t. groupid = gs. id_groups  order by t. staffid asc  limit $per_page,$item ";
      
    $sql mysql_query($query) or die("[B]Error ".mysql_errno()." :[/B] ".mysql_error()."");
      
    $return = array();
      while (
    $row mysql_fetch_assoc($sql)){
        
    $return[] = $row;
      }
     return 
    $return


    e questa e la funzione dove io diciaro le variabili
    Codice PHP:
    function PagerTech($page ,$item)
    {
      global 
    $dbcore;
      global 
    $settings ;
      global 
    $per_page,$item ;

    $array mysql_query("SELECT * FROM tech  where staffid = staffid ");
    $result mysql_num_rows($array);
        if (isset(
    $_GET['page'])) { $page intval($_GET['page']); } else { $page 1; }
        
    $per_page 1//Items per page
        
    $num_results $result//this value should arrive from some database query, like "select count(id) from table_you_want_to_page" 
        
    $item $num_results ;
        
    $item = ($page*$per_page)-$per_page;
        
    $query_string "class.pager.example.php?"// current file.. 
        
    $pr = new pager($num_results$per_page,$query_string); //building a pager
        
    $pr->num_results $num_results;
        
    $pr->per_page $per_page;
        
    $pr->query_string $query_string ;
        
    $range 9//set the range of page button list
        
    echo $pr->getRangeInfo();
        echo 
    $pr->getButList($range); 


    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    ciao nuovamente , qualcuno mi potrebbe aiutare a capire come risolvere questo intoppo?
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    ragazzi datemi una mano ho molta confusione , volevo dividere le funzioni ma non mi riesce mi date una mano
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  4. #4
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    prova questa query.. la tua ha sintassi sbagliata

    codice:
    select t.*  , gs.id_groups ,gs.nome_group from tech  as t  left join grouptech as gs  on  t.groupid = gs.id_groups  order by t.staffid asc  limit $per_page,$item
    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    ciao e grazie , ma il problema e che non so come passare le variabili limit che si trovano dentro una funzione a parte questa e la funzione :
    Codice PHP:
    function PagerTech($num_results$per_page,$query_string ,$item)
    {
      global 
    $num_results$per_page,$query_string ,$item ;


    if(!
    file_exists("classi/pagerclass/class.pager.php"))
    {
     return 
    false ;
    }
    require_once(
    "classi/pagerclass/class.pager.php");


      
     
    $array mysql_query("SELECT * FROM tech  where staffid = staffid ");
     
    $result mysql_num_rows($array);
      if (isset(
    $_GET['page'])) { $page intval($_GET['page']); } else { $page 1; }
        
    $per_page 1
        
    $num_results $result
        
    $item $num_results ;
        
    $item = ($page*$per_page)-$per_page;
        
    $query_string "index.php?_m=content&_s=managestaff";


        
    $pr = new pager($num_results$per_page,$query_string); //building a pager
        
    $pr->num_results $num_results;
        
    $pr->per_page $per_page;
        
    $pr->query_string $query_string ;
        
    $range 9//set the range of page button list
        
    echo $pr->getRangeInfo();
        echo 
    $pr->getButList($range); 

    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    non funziona cosi non mi estrae nemmeno i dati
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  7. #7
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    la soluzione che reputo piu probablie è

    questa
    http://it2.php.net/manual/en/language.constants.php
    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

  8. #8
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    Originariamente inviato da rocco.mod
    non funziona cosi non mi estrae nemmeno i dati
    che non te li estrae è un' altro discorso.. prima manco andava a cercarli!

    e a quello devi provvedere tu...
    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

  9. #9
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    si adesso li cerca e li legge , erano invertite le variabili , ti posso fare vedere una classe mi potresti aiutare
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    Codice PHP:
        class pager {
            
    /**
            * Number of results to show per one page
            * @var int 
            */    
            
    var $per_page;
            
    /**
            * Currently active page
            * @var int 
            */            
            
    var $page;
            
    /**
            * Page text in query string
            * @var string 
            */            
            
    var $page_identifier;        
            
    /**
            * NEXT button html code template 
            * "{query_string}" and "{page}" will be automatically replaced by the appropriate values 
            * @var string
            */            
            
    var $but_next "<a href=\"{query_string}&page={page}\">next</a>";
            
    /**
            * PREVIOUS button html code template
            * "{query_string}" and "{page}" will be automatically replaced by the appropriate values  
            * @var string
            */            
            
    var $but_prev "<a href=\"{query_string}&page={page}\">prev</a>";
            
    /**
            * Page ( ie.: 1, 2, 3, or 4, etc. ) button html code template 
            * "{query_string}" and "{page}" will be automatically replaced by the appropriate values 
            * @var string
            */                    
            
    var $but_page "<a href=\"{query_string}&page={page}\">{page}</a>";
            
    /**
            * Currently active page button html code template
            * "{query_string}" and "{page}" will be automatically replaced by the appropriate values  
            * @var string
            */                    
            
    var $but_page_this "[b]{page}[/b]";
            
    /**
            * Separator template 
            * Will be included among page buttons in page list   
            * @var string
            */                    
            
    var $separator " - ";
            
    /**
            * Range display template
            * "{from}", "{to}" and "{total}" will be automatically replaced by the appropriate values 
            * @var string
            */                    
            
    var $range_display "{to} of {total} ";        
            
    /**
            * Total number of results {from} -
            * @var int
            */            
            
    var $num_results;
            
    /**
            * Number of pages currently available 
            * @var int
            */            
            
    var $page_list_size;
            
    /**
            * Initial query string for use in button links 
            * Including "file.php?" (Ie.: "index.php?location=heaven")  
            * @var string
            */            
            
    var $query_string;
            
    /**
            * Pager initialization
            *
            * @param int $num_results total number of results ( you should get this from database before constructing the pager object )         
            * @param int $per_page number of results to display in one page 
            * @param string $query_string initial query string ( if you are using this pager to display search results, $query_string should arrive dynamically according to search query )
            * @param string $page_id page identifier variable in query string (ie.: "pg");
            */            
            
    function pager($num_results$per_page 10$query_string ''$page_id "page") {
                
    $this->page $_REQUEST[$page_id] ? $_REQUEST[$page_id] : 1;
                
    $this->page_identifier $page_id;
                
    $this->per_page $per_page;
                
    $this->num_results $num_results;
                
    $this->query_string $query_string;
                
    $this->page_list_size ceil$this->num_results $this->per_page );
            }
            
    /**
            * Gets the result offset for a page.
            * NOTICE: If you want to use this function to
            * show the logically correct value for output in html (Ie.: "showing results 1 - 10"), 
            * you should increase the result of this function by 1 (because in real life results 
            * start from 1, not from 0)  
            *
            * @param int $page the page you want to get the offset for
            * @returns int         
            */            
            
    function getPageFrom($page) {
                if(
    $page <= 0) return 0;
                if(
    $page $this->page_list_size) return 0;
                
    $result = ($page-1) * $this->per_page;
                
    $result = ($result >= $this->num_results) ? ($this->num_results 1) : $result;
                return 
    $result;
            }
            
    /**
            * Gets the tail value of results shown in a page. 
            * NOTICE: Do NOT use the results of 
            * this function in database query, it's for outputting the range only.
            * (Ie.: "showing results 1 - 10")
            *
            * @param int $page the page you want to get the tail for
            * @returns int         
            */            
            
    function getPageTo($page) {
                if(
    $page <= 0) return 0;
                if(
    $page $this->page_list_size) return 0;
                
    $result = ($page-1) * $this->per_page $this->per_page;
                
    $result = ($result >= $this->num_results) ? $this->num_results $result;
                return 
    $result;
            }    
            
    /**
            * Generates the NEXT button html code from the predefined template 
            * (check initial vars for more information)
            *
            * @param int $page the page you want to get the NEXT button for ( usually the active page )
            * @returns string
            */            
            
    function getButNext($page) {
                
    $page++;
                if(
    $page $this->page_list_size) return "";
                if(
    $page 1) return "";
                
    $temp ereg_replace("{query_string}"$this->query_string$this->but_next);
                
    $result ereg_replace("{page}", (string)$page$temp);
                return 
    $result;
            }
            
    /**
            * Generates the PREVIOUS button html code from the predefined template 
            * (check initial vars for more information)
            *
            * @param int $page the page you want to get the PREVIOUS button for ( usually the active page )
            * @returns string
            */        
            
    function getButPrev($page) {
                
    $page--;
                if(
    $page 1) return "";
                if(
    $page $this->page_list_size) return "";
                
    $temp ereg_replace("{query_string}"$this->query_string$this->but_prev);
                
    $result ereg_replace("{page}", (string)$page$temp);
                return 
    $result;
            }        
            
    /**
            * Generates the PAGE button html code from the predefined templates 
            * (check initial vars for more information)
            *
            * @param int $page the page you want to get the PAGE button for
            * @returns string
            */                    
            
    function getButPage($page) {
                if(
    $page 1) return "";
                if(
    $page $this->page_list_size) return "";
                
    $source = ($page == $this->page) ? $this->but_page_this $this->but_page;
                
    $temp ereg_replace("{query_string}"$this->query_string$source);
                
    $result ereg_replace("{page}", (string)$page$temp);
                return 
    $result;            
            }
            
    /**
            * Generates the Google style PAGE button list html code from the predefined templates 
            * (ie.: "1 - 2 - 3 - 4 - 5", check initial vars for more information)
            *
            * @param int $range number of page buttons to be shown before and after tbe current page 
            * @returns string
            */            
            
    function getButList($range 9) {
                
    $range++;
                unset(
    $result);
                for(
    $i = ($this->page $range); $i <= ($this->page $range); $i++) {
                    if(
    $this->page $range) {
                        
    $result .= $this->getButPage($i);
                        if (
    $i == $range) break;
                    }
                    else 
    $result .= $this->getButPage($i);
                    if(
    $this->getButPage($i+1) && $result && $i $this->page $range
                        
    $result .= $this->separator;
                }
                return 
    $result;
            }
            
    /**
            * Generates the result range information text from the predefined template 
            * (ie.: "Displaying 1 - 3 of 24", check initial vars for more information)
            *
            * @returns string
            */                
            
    function getRangeInfo() {
                
    $from $this->getPageFrom($this->page) + 1;
                
    $to $this->getPageTo($this->page);
                
    $temp ereg_replace("{from}", (string)$from$this->range_display);
                
    $temp ereg_replace("{to}", (string)$to$temp);
                
    $result ereg_replace("{total}", (string)$this->num_results$temp);
                return 
    $result;
            }
            
        
        } 
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.