Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Escludere domande

  1. #1

    Escludere domande

    Codice PHP:
    $query6 "SELECT * FROM risposte WHERE Utente = '$IDAccount' AND Test = '$IDTest2' ORDER BY ID";
    $result6 mysql_query($query6$db);
    while (
    $row6 mysql_fetch_array($result6)) {
    $DomandaFatta $row6["Domanda"];

    $query4 "SELECT * FROM domande WHERE Test = '$IDTest2' AND ID != '$DomandaFatta'";
    $result4 mysql_query($query4$db);
    $row4 mysql_fetch_array($result4);
    $IDDomanda $row4["ID"];
    $TestoDomanda $row4["Domanda"];


    Fino alla seconda domanda tutto ok, alla terza mi mostra le prime 2 e non la terza. Dove sbaglio?

  2. #2
    Perchè nel ciclo ripeti la query escludendo un rigo solo.

    Quindi ti prende la 1
    poi la prima che non è la 1 (la 2)
    poi la prima che non è la 2 (la 1)
    poi la prima che non è la 1 (la 2)
    poi la prima che non è la 2 (la 1)

    Oltretutto credo che potresti risolvere con una query sola, posta la struttura delle tabelle

  3. #3
    codice:
    <?
    $query6 = "SELECT * FROM risposte WHERE Utente = '$IDAccount' AND Test = '$IDTest2' ORDER BY ID";
    $result6 = mysql_query($query6, $db);
    while ($row6 = mysql_fetch_array($result6)) {
    $DomandaFatta = $row6["Domanda"];
    
    $query4 = "SELECT * FROM domande WHERE Test = '$IDTest2' AND ID != '$DomandaFatta'";
    $result4 = mysql_query($query4, $db);
    $row4 = mysql_fetch_array($result4);
    $IDDomanda = $row4["ID"];
    $TestoDomanda = $row4["Domanda"];
    
    echo "Question $Domanda/$TotDom
    
    
    
    $TestoDomanda";
    ?>
    <form action="pag.php?Pag=res_question" method="post" name="Question">
    <input name="Quest" type="hidden" value="<? echo $IDDomanda ?>" />
    <?
    $query5 = "SELECT * FROM multiple WHERE Domanda = '$IDDomanda' ORDER BY ID";
    $result5 = mysql_query($query5, $db);
    $TotMult = mysql_num_rows($result5);
    if ($TotMult > 0) {
    echo "<ul style=\"list-style:none\">";
    while ($row5 = mysql_fetch_array($result5)) {
    $IDMult = $row5["ID"];
    $TestoMult = $row5["Testo"];
    
    echo "[*]<input type=\"radio\" name=\"Mult\" value=\"$IDMult\" /> $TestoMult";
    
    }
    }
    ?>
    <center>
    Texte
    
    <textarea name="Text" cols="35" rows="7"></textarea>
    
    
    
    <input name="Envoyer" type="submit" value="Envoyer" /> <input name="Supprimer" type="reset" value="Supprimer" />
    </center>
    </form>
    <?
    }
    ?>

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.