0

the form already has an existing submit button which you can select difficulty(1st combo) and location(2nd combo) and then i submit this to display a video and a text field

under the field i have an addtional drop down box which is yes or no

then inside this code i want to submit a separate value using an if inisde an if it works fine on the 1st difficulty and location in the lists but nothing else and i cant see what im doing wrong a new pair of eyes would be great PS i will be upgrading this to PDO eventually

    <?php 
if(strpos($drop, 'norm') !== false && $ruavalue == 0) 
{
    Echo "RUA: ";
    $RUAresult = mysql_query("SELECT Answer FROM options"); 
    echo "<select name='ruacombo'>"; 
    while($RUArow = mysql_fetch_assoc($RUAresult)) 
    echo "<option value = '".$RUArow['Answer']."'>".$RUArow['Answer']."</option>";
    echo "</select>"; 
    echo '<form action="" method="post">';
    echo "<input name=\"boss\" type=hidden value=".$_POST['tier_two'].">";
    echo "<input name=\"main\" type=hidden value=".$_COOKIE['ID_my_site'].">";
    echo '<input type="submit" name="ruasubmit" value="RUA!" />';
    echo '</form>';
    if (isset($_POST['ruasubmit']))
     { 
        $ruaboss = $_POST['boss'];
        $ruauser = $_POST['main'];
        $ruasql = "UPDATE `RUASEXCELL` SET `$ruaboss`=1 WHERE Username = '$ruauser'";

        $add_rua = mysql_query($ruasql);

    }   
3
  • hmmm.. could you clarify where/what is the problem and narrow your code example? Commented Apr 11, 2014 at 22:30
  • i have edited my code to just one of the functions my issue is when i hit submit it is not updating the value in mysql $tier_two is set by a previous submit in the form Commented Apr 11, 2014 at 23:59
  • 2
    You might start by putting in proper error handling around your database accesses to see if there are errors in your queries. You also, really should learn about SQL injection and how to prevent it. Commented Apr 12, 2014 at 0:02

1 Answer 1

1

In your while loop, you need to access the associative array keys as a string like so:

while($RUArow = mysql_fetch_assoc($RUAresult)) 
    echo "<option value = '".$RUArow['Answer']."'>".$RUArow['Answer']."</option>"; 

Also, please look into using mysql_real_escape_string() to prevent SQL injection. In its current state, this script, and your database can be blown to pieces by a stray quote.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.