Jump to content

Recommended Posts

I retrieve two  fields from a mysql table using the  snippet below.  The two values are incorporated into a list box.  That works fine.  The title is presented in the list box since this is the value that will make sense to the user but the unique ID for each record is written into the value for each list item.  I would like the user to make their choice and based on that choice some data gets written back to the originating table.  I can retreive the users choice of 'title' but I also need the 'id' value  in order that I can write the data back to  correct the originating row.  How can PHP be used to source id?    (value='$row->id')

 

    <?php

    foreach ($rows as $row) {

      echo "<option value='$row->id'>$row->title</option>";

    }

    ?>

    </select>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/184448-retreive-list-box-value/
Share on other sites

if $row->id is the id, than simply doing

$id = $_POST['Select_Form_Name'];//replace select form name with whatever your select is called

 

should get the id that the user selected...

 

I don't really see how you could get the title, the title isn't passed into the post variables, the value attribute is

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.