PHP Select Option MYSQL

Asked

Viewed 1,050 times

1

I have a page where the person Adds Database values.

<?php   
    $get = ("SELECT movie_id, movie_name FROM movies ORDER BY movie_name DESC");
    $result2 = mysqli_query($con, $get);

    $option = '';

    while($row = mysqli_fetch_array($result2))
    { 
      $option .= "<option value = '".$row['movie_id']."'>".$row['movie_name']."</option>";
    }
?>           

<form action="includes/reload.php" method='POST'>
    <select name="selectionD" id="fname">         
        <?php
            echo "<option value='0'>Escolha a Serie...</option>";
            echo "<option value='0'></option>";
            echo $option;
        ?>        
    </select>          

   <input type="text" class='' id="fname" name="sess" maxlength='3' placeholder="Nº Temporada" required>
   <input type="hidden" value='' name="movid"  hidden>
   <input type="text" id="fname" name="episode" maxlength='3' placeholder="Nº Episódio" required>

    <br/>
    <input type="submit" value="Adicionar" name='saveNew'>
</form> 

The result is to add entries in the Database with the values $movie_id, session and episode...

But I also wanted to add the name of the Episode, as you see in <.Option.> Name <.Option.>.. $Row['movie_name']... I can only use it as text...

Is there any way to add also the name of the movie along with the option chosen in OPTION?

Example.. If I choose Option 1, it loves the desired DB Value, but I can’t get it to also store the NAME.

  • As for the code without difficulties, the difficulty is to understand what you want with this "keep also the NAME"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.