[SOLVED] MySQL query inside query while loop not working (PHP)


BIG EDIT: I’ve trimmed the code as much as possible while getting the same notice.
So I’m trying to use the variable $tour which is defined in the first if(isset.... This if creates a second submit that when pressed should print the value $tour but I get the following output:

Notice: Undefined variable: torneo in /home/user/public_html/edit/file.php on line 19
before loop

Notice: Undefined variable: torneo in /home/user/public_html/edit/file.php on line 21

The trimmed code is:

<form method="POST">
TORNEO: <select name="torneo">
            <option value="DSHN ADULTO">DSHN ADULTO</option>
            <option value="NFL">NFL</option>
<br />
<input type="submit" value="ELEGIR" name="input1"/>
<br />
    $torneo = $_POST['torneo'];
    echo $torneo;
    echo "<br><input type='submit' name='input2' value='CREAR'/>";
    echo $torneo."1";
    echo "<br>before loop<br>";
    while ($torneo){
        echo "Updated! ".$torneo."<br>";        

Thanks for the help!


The answer to my problem is here:

Why do I keep losing variable values when submitting a second form on the same page

Thanks everyone who helped, Im really very thankful to all!

Answered By – Enric Grau-Luque

Answer Checked By – Mildred Charles (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *