PHP Show all data from a ROW in OPTION and INPUT

Asked

Viewed 57 times

0

As you are creating a half-complete project...

I made a FORM with the <.OPTION.> and <.input option..>

what I want is... to make a Loope where in this option it takes with it as POST the ID, NAME, EMAIL all of a single Rows example.

nome | email| id
 1   |  @1  |  1
 2   |  @2  |  2
 3   |  @3  |  3 

  Se escolher esta <option>1</option>, ele posta tudo da row 1.

How do I do that?... I’m lost.

I tried it like this, but he just showed it all just 1 detail on Row and the rest off Row.

    while($row = mysqli_fetch_array($result2))
    { 
      echo "<option value = '".$row['id']."'>".$row['movie_name']."</option>";
      echo "</select>";
      echo "<input type='hidden' value='".$row['movie_name']."' name='movname'  hidden>";
      echo "<input type='hidden' value='".$row['movie_img']."' name='movimg'  hidden>";
    }

Simply take all the ROW Values and take along with the chosen OPTION and prepare the POST and add everything... as I do?

  • Could show sql query before while?

  • 1

    Why do you finish the </select> inside the while without starting it inside that loop?

  • The point is not... the point is I want to use All Name Details 1 in just 1 OPTION.... And not just 1 value per each...

  • Wow, it’s hard to understand. put the whole code in please.

  • Fuck, I want this <option value="'$Row['id'] . $Row['movie_name'] . $Row['movie_img']'">'$Row['movie_name']'</option>, so that later ADD to another table all these data.

1 answer

0

Viewing the comment of the questioner:

....., I want this

<option value="'$row['id'] . $row['movie_name'] . $row['movie_img']'">'$row['movie_name']'</option>

so that later ADD to another table all these data.

We have to construct inputs separated by a "separator". In the example below the separator is a comma , but it can be anyone who is not present in the data of the consultation.

echo "<option value=".$row['id'].",".$row['movie_name'].",".$row['movie_img'].">".$row['movie_name']."</option>";

If $Row['id']=1, $Row['movie_name']= Os dalmatas and $Row['movie_img']= img1

the result of $_POST["nameSelect"] is 1,Os dalmatas,img1

From now on it’s up to explode and foreach

Browser other questions tagged

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