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

    variabile doppiamente definite.

    salve ragarri buon giorno avrei bisogni di un vostro aiuto piu che problema, e un consiglio da parte di qualcuno piu' esperto di me..... vi spiego io ho due funzionei , una estraggo gli user e l altra per la paginazione, adesso la domanda è: che queste due funzioni , si troano in due files diversi , ma a tutte e due devo dichierare le stesse variabili
    in una serve per la query limit $xxxxxx,$ffffff
    e l altra funzione per i valori del da smistare come potrei fare a dichiararleuna sola volta?
    posto le funzioni
    Codice PHP:

    function PagerTech( )
    {
    global 
    $page $ofsppg $ofsppg;
    if (isset(
    $_GET['page'])) { 
    $page intval($_GET['page']); } else {$page 1; }
    $ofsppg 1//Items per page
    $ofsbgn = ($page*$ofsppg)-$ofsppg;
    require_once 
    'classi/pagerclass.php';
    $pager = new pager();
    $query  "select * from tech where staffid = staffid ";
    $sql mysql_query($query );
    $total =  mysql_num_rows($sql);
    $pager->override_query $total;
    $pager->items $ofsppg;
    $pager->actpg $page;
    $pager->url "index.php?_m=content&_s=managestaff&page={{N}}";

    echo 
    $pager->show();

    }    
        
    /**
        * view  tech 
        */
    function GetStaff()
    {
      global 
    $dbcore;
      global 
    $settings ;
    global 
    $page $ofsppg $ofsppg;
     if (isset(
    $_GET['page'])) { 
    $page intval($_GET['page']); 
    } else { 
    $page 25; }
    $ofsppg 1//Items per page
    $ofsbgn = ($page*$ofsppg)-$ofsppg;

      
    $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 $ofsbgn , $ofsppg";
      
    $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


    vorrei dichiararle solamente nella funzione pagerttech ma che i valori limit siano riconosciuti dalla funzione gettech grazie
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    salve ho tolto le variabili alla query lasciando le variabili come global , ma mi stampa un errore
    codice:
    Notice: Undefined variable: ofsbgn in C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\supp\includes\function_staff.php on line 81
    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 ' 1' at line 1
    perche trova le due variabile della query che seguono dopo limit le trova indefinite , però io le ho definite gia in un altra funzione cosa fare ?????
    Codice PHP:





    function PagerTech()
    {
    global 
    $page $ofsppg ;
     if (isset(
    $_GET['page'])) { 
    $page intval($_GET['page']); 
    } else { 
    $page 1; }
    $ofsppg 1//Items per page
    $ofsbgn = ($page*$ofsppg)-$ofsppg;

    if(empty(
    $page) or empty($ofsppg))
    {
    exit(
    "query vuote");
    }

    require_once 
    'classi/pagerclass.php';
    $pager = new pager();
    $query  "select * from tech where staffid = staffid ";
    $sql mysql_query($query );
    $total =  mysql_num_rows($sql);
    $pager->override_query $total;
    $pager->items $ofsppg;
    $pager->actpg $page;
    $pager->url "index.php?_m=content&_s=managestaff&page={{N}}";

    echo 
    $pager->show();


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

  3. #3
    non puoi passare i parametri alla funzione?????
    V.I.S.T.A. --> Virus Inside, Switch To Apple

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    no non li riesco a passare
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  5. #5
    Dichiarale global nella funzione, e non due volte la stessa come fai qui:

    Codice PHP:
    function PagerTech( ) 

    global 
    $page $ofsppg $ofsppg
    e qui:
    Codice PHP:
    function GetStaff() 

      global 
    $dbcore
      global 
    $settings 
    global 
    $page $ofsppg $ofsppg



    Ciao!

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    ma l' fatto in tutte e due le funzioni le ho fatto globali le variabili, ma in una dentro le dichiaro
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    mi stampa questo errore nella query , perche non capisce la variabile ce sta dopo i limit
    codice:
    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
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  8. #8
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    ciao a tutti come posso passare le variabili definite dentro ad una funzione , ad un altra funzione ?
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  9. #9
    quando dichiari la funzione scrivi ad ex:


    Codice PHP:
    function ciao ($a,$b) {

    //la funzione



    quando la chiami


    Codice PHP:
    ciao($variabile1,$variabile2); 
    $variabile1 verrà copiato in $a e $variabile2 in $b....
    V.I.S.T.A. --> Virus Inside, Switch To Apple

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,805
    grazie mr.click
    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.