Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2001
    Messaggi
    131

    variabili dinamiche (si incrementa)

    Come si può fare che una variabile prova1 si incrementi e diventi prova2 ecc?
    io faccio una query e metto tutto su delle variabile dinamiche

    Codice PHP:
    echo "<form action='articolo2.php?login=" $login "' method=GET>";
    ....
    ....
    while (
    $row mysql_fetch_array($result))
    {
    $i ++; 
    $stefano "stefano" $i;
    $art "art" $i;
    $opz"opz" $i;
    echo 
    "<td><input type=text name=" $stefano " size=2 value=0></td>
    <td><input type=hidden name=" 
    $art " size=0 value='"$row['articolo'] . "'></td>
          <td><input type=hidden name=" 
    $opz " size=0 value='"$row['opzione'] . "'>
          <input type=hidden name=num_righe size=2 value=" 
    $i "></td></tr><tr>";
    };

    echo 
    "<p align=center><input type=submit value=Ordina></td></form>"
    nella pagina articolo2.php se faccio echo $art1... $art2 ottengo i dati
    pero onde evitare di scrivere 100 possibili art volevo fare un while ma come faccio a fare in modo che il nome della variabile si incrementa?

  2. #2

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2001
    Messaggi
    131
    Originariamente inviato da Insaponata
    usi gli array
    dici nel submit?
    dovrei serializzarli ma poi per qualche arcano motivo quando vado nell'altra pagina e faccio deserialize non c'è nulla???

  4. #4

    ........

    Ciao.
    Prova questa:
    Codice PHP:
    function getPostValue()
    {
        
    $newArray = array();
        foreach(
    $_POST as $key => $value)
        {  
            
    $pos strpos($key,'art');
            if(
    $pos !== false)
            {
                
    $newArray[$key] = $value;
            }
        }
        return 
    $newArray;


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2001
    Messaggi
    131
    mi da pagina bianca....

  6. #6

    .......

    Codice PHP:
    <?php
    function getPostValue()
    {
        
    $newArray = array();
        foreach(
    $_POST as $key => $value)
        {  
            
    $pos strpos($key,'art');
            if(
    $pos !== false)
            {
                
    $newArray[$key] = $value;
            }
        }
        return 
    $newArray;
    }
    if(isset(
    $_POST['checherLogin']))
    {
    print_r(getPostValue());
    }
    ?>
    <form id="frmLogin" name="frmLogin" action="index.php" method="post">
    <input type="hidden" name="checherLogin" value="1163145905" />
    <input type="hidden" name="poster" value="yes" />
    <label>Username : </label>
    <input type="text" name="art1" value="" maxlength="32" /><br class="frmClear" />
    <label>Password : </label>
    <input type="password" name="art2" value="" maxlength="32" /><br class="frmClear" />
    <label>Remember your access : </label>
    <input type="checkbox" id="remember" name="remember" value="1" /><br class="frmClear" />
    <label></label>
    <input type="submit" name="login" value="Login" />
    </form>
    Con questo form funziona


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

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 © 2024 vBulletin Solutions, Inc. All rights reserved.