Dynamic list/menu update page

Hi,
I am using PHP, Mysql.  MySQL has different tables.  Created list/menu to show data off one of the table that works great and when I select the value and hit the updae button it updates the database correctly.  Problem I am having is that when I go to update the page again, it always defaults to the first value of the drop down list.    I need it to remember the value that was selected.  Hope this explains it well.

Hi,
So the first example I am posting is pretty much the same idea as what Gunter wrote, Gunter wrote the way to handle it in dreamweaver.
This example is what happens in the code after the DW wizard does its thing.
Right before it submits to the database you can create a session of the value.
$_SESSION['cat_id'] = $_POST['cat_id'];
Then use a string compare command to check against the session.
(If session cat_id is the same as the recordset cat_id value then echo that line as selected)
<?php if (!(strcmp($row_listCategories['id'], $_SESSION['cat_id']))) {echo "selected=\"selected\"";} ?>
Here it is included in your code sample:
<select name="cat_id" multiple="multiple" size="5" id="cat_id">
          <?php do { ?>
          <option value="<?php echo $row_listCategories['id']?>"<?php if (!(strcmp($row_listCategories['id'], $_SESSION['cat_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_listCategories['cat']?></option>
          <?php
                } while ($row_listCategories = mysql_fetch_assoc($listCategories));
                  $rows = mysql_num_rows($listCategories);
                  if($rows > 0) {
                      mysql_data_seek($listCategories, 0);
                      $row_listCategories = mysql_fetch_assoc($listCategories);
            ?>
        </select>
Note that at the top of your page you will need to initiate the session:
session_start();
NOTE: This is example takes note that you added the multiple="multiple" tag to your select. If you want it so someone selects two items then after the update you want to call on both select items. (so all they selected is still selected, not just the last item.).
    <select name="select[]" id="select" multiple="multiple">
      <?php do { ?>
      <?php if (is_array($_SESSION['cat_id'])) { ?>
      <option value="<?php echo $row_listCategories['id']?>"<?php if (in_array($row_listCategories['id'], $_SESSION['cat_id'])) {echo "selected=\"selected\"";} ?>><?php echo $row_listCategories['cat']?></option>     
      <?php } else { ?>
      <option value="<?php echo $row_listCategories['id']?>"<?php if (!(strcmp($row_listCategories['id'], $_SESSION['cat_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_listCategories['cat']?></option>
      <?php } ?>     
          <?php
                } while ($row_listCategories = mysql_fetch_assoc($listCategories));
                  $rows = mysql_num_rows($listCategories);
                  if($rows > 0) {
                      mysql_data_seek($listCategories, 0);
                      $row_listCategories = mysql_fetch_assoc($listCategories);
            ?>
    </select>
You will probably have to make an adjustment to your database input query to handle the array $_POST['cat_id']. I didnt have time to test that part.

Similar Messages

  • Dynamic List/Menu After Update

    Hi All,
    Dreamweaver - ASP
    I have a form to add records. The first field is a dynamic list/menu to select the date.
    After the Add record button is pressed the page reopens but the date menu has reverted to "Select date"
    Is there a way to retain the previously chosen date when the page refreshes?
    Many thanks
    John

    Hi All,
    Solved the problem.
    I set  up a session variable for the date and then used the 'Dynamic' button for the List/Manu, Select Value equal to,  and selected the session variable.
    Regards
    John

  • Dynamic List to Update Field in  Record

    Hello,
    I have created an Update page in CS5.5 and have added a dynamic list to update a field in the record. Now I am stuck. How do I modify the code in the menu to have it update the field? 
    <select name="cemeteryID">
    <?php do {  ?>
    <option value="<?php echo $row_cemeteryList['cemeteryID']?>"<?php if (!(strcmp($row_cemeteryList['cemeteryID'], $row_cemeteryList['']))) {echo "selected=\"selected\"";} ?>><?php echo $row_cemeteryList['cemetery']?></option>
                  <?php
                  } while ($row_cemeteryList = mysql_fetch_assoc($cemeteryList));
                  $rows = mysql_num_rows($cemeteryList);
                  if($rows > 0) {
                  mysql_data_seek($cemeteryList, 0);
                  $row_cemeteryList = mysql_fetch_assoc($cemeteryList);
    ?>
    </select>
    Thanks!

    I figured it out.  Suprised that no one responded - oh well.

  • Dynamic List/Menu with 2 columns

    I have created a Dynamic List/Menu box based on a recordset and showing me one field of that recordset ['Firmanaam'].
    <?php
    do { 
    ?>
                <option value="<?php echo $row_klantenselectie['Firmanaam']?>"><?php echo $row_klantenselectie['Firmanaam']?></option>
                <?php
    } while ($row_klantenselectie = mysql_fetch_assoc($klantenselectie));
      $rows = mysql_num_rows($klantenselectie);
      if($rows > 0) {
          mysql_data_seek($klantenselectie, 0);
       $row_klantenselectie = mysql_fetch_assoc($klantenselectie);
    ?>
    First question what is the difference between 'values" and 'labels' in the creation box of the Dynamic List/menu as only the field entered in the 'labels" is shown in the listbox ?
    Secondly I want to display two columns in the List box (one column with the client ID and one column with the clients name). How do I proceed ? Afterwards clicking on the selected client should send the client ID to another field in the form.
    Thank you for your replies.

    Moved to the Develop server-side applications in Dreamweaver forum, which deals with this sort of issue.
    First question:
    The Values field in the Dynamic List/menu dialog box populates the value attribute in the opening <option> tag. Because it's an HTML attribute, it's not displayed when the page is rendered in a browser. The Labels field puts the text that will be displayed in the drop-down menu between the opening and closing <option> tags.
    Put the value you want displayed in the Labels field, and the value you want sent to the server when the form is submitted in the Values field.
    Second question:
    Normally, you would put the ID in the Values field, and the name in the Labels field.
    Because the value attribute will contain the ID, it shouldn't normally be necessary to populate another field with the selected value because the ID will be sent to the server with the rest of the form data when the form is submitted.

  • PHP/Dreamweaver dynamic list menu

    I have a mySQL DB that has address listings on it, I have
    used the city column to populate a list menu dynamically w/ PHP...
    No problems so far- but I cannot figure out how to have each city
    listed only one time.
    In other words, say I have 20 of the same city listed on the
    DB column. I want each city to be listed once in the list menu....
    Any idea??? I have been thinking about it all day w/ out any
    luck!
    Thanks in advance,
    -B

    .oO(Steve)
    >On Wed, 7 Feb 2007 03:16:54 +0000 (UTC), "za beezo"
    ><[email protected]> wrote:
    >
    >> In other words, say I have 20 of the same city
    listed on the DB column. I want
    >>each city to be listed once in the list menu....
    >
    >SELECT DISTINCT instead of just SELECT
    Or a GROUP BY clause, which is what I usually prefer. But in
    this case
    it shouldn't matter.
    Micha

  • IE 8 not placing list menu on page

    Hi,
    I am on Apex 4.0.1 and created a list region on page zero to show up on page template Region 3 on some pages of my applications. It shows up exactly where I want it on Firefox, Safari and Chrome, but on IE 8 it is off the page to the right. You can barely see part of the left edge of the list which is supposed to show up on the right side of the browser so it is completely unusable. It shows up complete on the other browsers. Anyone have any idea how to fix this so it is visible in IE.
    Thanks,
    Pat

    patfmnd wrote:
    Hi,
    I am on Apex 4.0.1 and created a list region on page zero to show up on page template Region 3 on some pages of my applications. It shows up exactly where I want it on Firefox, Safari and Chrome, but on IE 8 it is off the page to the right. You can barely see part of the left edge of the list which is supposed to show up on the right side of the browser so it is completely unusable. It shows up complete on the other browsers. Anyone have any idea how to fix this so it is visible in IE.Not without seeing it. Please reproduce on apex.oracle.com.

  • Dynamic List/Menu question

    Is it possible to add a default item at the top of static options area of a dynamic menu which does not perform any function when activated?
    I have a "Please choose an option" as my static option at the top of the menu. When the "Go" button is clicked when the "Please choose" is visible I would like this to do nothing and only show a results page when any of the active menu options are selected and "Go" clicked.

    Hello Phil,
    Open  the page for which u want to hide the dynamic navigation bar,   there is a property named <b>Initial State of Navigation Panel</b>.
    Just set it to <b>close</b>.
    This will solve the problem.
    Regards
    Deb
    [Rewards points for helpful answers]

  • Ensure List/Menu populate my update form with the correct data before update

    Hello,
    Please how do I ensure my update form is populated with the correct data before update?
    On my update page I have text fields and select fields (dynamic list/menu). When I open my profile page to make updates, I see the field well positioned in the text fields but in the select list/menu fields, I see "Select from list" instead of the value that was initiated selected
    Correct Values before update
    Wrong values during update
    As you can see from the images below, when I open the update page, the list automatically populate the select fields with the last values in the list instead of the Initial values that where selected by the user before the update.
    Can anyone please review and let me know where I have gone wrong.
    Thank you
    Mike

    Hello All,
    Once more thank you. I have sorted the issue out.
    I observed that I was selecting the wrong field. I selected the field matching the record set of the select instead of the field matching the record set of the table I am working as seen on the image belew
    I was selecting this - This is the record set of the table that hold values for the city select list
    Instead of this. This is the record set of the table behind the form I am working on
    My issue is now re-solved.
    Mike

  • WPC 7.3 : Dynamic List : pager

    We have been working in WPC 7.3 with Dynamic Lists : this can be used to display news items similar to XML forms, mixed with own forms.
    The Dynamic List iView, once added onto the WPC page can be configured to display the number of items.
                    Example : 4 items. Letu2019s say we have 6 items, then only the four u2018newestu2019 are shown.
    What is missing here is a u2018pageru2019 at the bottom , in case somebody wants to see the other two, older items.
    There is no standard pager in  the KMCWPC05P_3-10008779.SCA file -> com.sap.nw.wpc.dynamicList.sda project.
    Before we actually start to develop our own Dynamic List project with pager : anybody managed to add this piece of vital coding?
    Or perhaps this is planned for the future?

    I got a solution regarding this topic.
    I followed these steps:
    You must set the number of items in you example to six or higher (in your example, the remaining two items wouldn't even get rendered)
    You surrounded your Dynamic List layout with "<li>...</li>"
    In your theme, you implement a JQuery Paginator (e.g. look here), which works with the list-elements
    Tell your paginator to show four items per page
    I got something going like this:

  • Unable to use #A01# substitution variable in dynamic list

    Greetings...
    I am attempting to generate a dynamic list on the page.  The list will contain a flag indicating whether the list entry is actually hidden to the user or not.  If it is hidden to the user, then I want to apply a particular class to that list entry when rendered.
    The dynamic list has the following SQL:
    SELECT null lvl,
           menu.menu_nm label_value,
           q'!javascript:$s('P32_MASTER_MENU_ID', '!' ||
              menu.menu_id || q'!');!' target_value,
           null image,
           null image_attribute,
           null image_alt_attribute,
           case when menu.hidden = 'Y'
                  then 'class="hiddenNode"'
                  else null end attribute1
    from ( select 'N' hidden, vis.* from std_vw_apex_menu vis
            union all
           select 'Y' hidden, hid.* from std_vw_apex_menu_hidden hid ) menu
    where menu.menu_ty = 'MAINMENU'
    order by menu.sort_order
    I am then using a list template with the following as the "Current" list entry:
    <li class="active"><a href="#LINK#"><span #A01#>#TEXT#</span></a></li>
    ... and the following as the "Non-Current" list entry:
    <li><a href="#LINK#"><span #A01#>#TEXT#</span></a></li>
    The result I see in the rendered page however is that the substitution is not happening, as indicated in the following snippet :
    <li><a href="javascript:$s('P32_MASTER_MENU_ID', '18893191201');"><span #a01#="">Education</span></a></li>
    We are on ApEx 4.2.1.  What am I doing wrong as I've seen other threads indicate that it is possible for dynamic lists to use substitution variables in their list templates.
    Shane.

    I found the solution at Attribute substitution  not working in templates for dynamic lists.

  • HELP - List Menu 2 fields?

    I have a recordset that returns a list of Manager names and
    corresponding Manager ID numbers, which are two separate fields in
    my database. I would like to create a dynamic list menu and display
    both fields. This list menu would be used to drive another search
    based on the what was selected from the menu. I need to be able to
    only select the manager ID number for the search since it is unique
    whereas the manager name could have duplicates. Is this possible???
    Your help is appreciated in advance

    Do you really need them shown? - i.e. a refresh?
    or are you just looking to update 3 fields in the database?
    If you are looking to update the database, you can use the
    $_POST variable to insert into as many fields in the record as you
    want. But his would be done in the MySQL statement, not the
    form.

  • Error in adding dynamic list in site studio

    When i add a dynamic list to my page in site studio and view it in my browser, i don't get results. When i look in the logs i see following error:
    Parsing error at character 68 in query: "((dExtension <matches> `doc`) <and> (xWebsites <contains> `intranet`)) <and> <not> (xDontShowInListsForWebsites <contains> `intranet`)" Query operator hasAsWord does not exist
    I only add de dExtension <matches> 'doc' THe rest is generated i guess.... How can i resolve this error?

    Well, the problem is solved.
    I hadn't installed the DBSearchContainsOpSupport component. Because of that, i hadn't any fields in the Zone fields witch lead to the error.
    WHen i installed and configured that component, i worked.

  • Includes from list, Dynamic list/form and Apache mod_rewrite

    Hi, I have:
    index.php (with includes from list)
    activity.php (a dynamic list as included page)
    activity_edit.php (a dynamic form as included page)
    I want to use SEO friendly url.
    But links from my "List" pointing my "Form" (edit, add new) don't work
    Is there a way? Thanks
    Gabriele

    Hi, I have:
    index.php (with includes from list)
    activity.php (a dynamic list as included page)
    activity_edit.php (a dynamic form as included page)
    I want to use SEO friendly url.
    But links from my "List" pointing my "Form" (edit, add new) don't work
    Is there a way? Thanks
    Gabriele

  • Dynamic lists performance impact

    Hi
    I am interested in finding out what the performance impact of using Site Studio dynamic lists fragments on a web page are. Is the query executed each time the page is loaded? If I place more than one dynamic lists on a page how will that impact the performance?
    Thx,
    Vaylee

    Hi Vaylee,
    unless you cache your results query executes each time. I guess the impact will not be that high, as pages are processed before they are served from UCM this will add only a little to the existing process.
    cheers,
    sapan

  • List/Menu Customization

    How does one go upon customizing the text color and
    background of a List/Menu item? Can someone point me in the right
    direction?
    Thanks!

    slegendre wrote:
    > Chin Chin,
    >
    > Not sure this is what i'm looking for. The Menu I would
    like to customize is a
    > dynamic list menu. Basically its a dynamic menu that
    pulls all the US states
    > from a database. So default it says "Choose a State",
    when you click the drop
    > down it displays all the US states.
    >
    > I'm trying to change the text a color that matches the
    website, as well as the
    > background of this menu. Eventually I would like to have
    little icons of the
    > state with the states name, but thats proabably a bit
    advanced for me.
    Oh yes I see - I don't think that you will be able to use
    icons - but
    you could try something like this.....
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    select {
    background: #000000;
    color: #FFCC66;
    -->
    </style>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
    <select>
    <option selected="selected">Choose a
    State</option>
    <option>popopoopopopo</option>
    <option>oioio</option>
    </select>
    </form>
    </body>
    </html>
    HTH
    chin chin
    Sinclair

Maybe you are looking for