Skip navigation
okolawol
Currently Being Moderated

Issue with showing a menu drop down in Record Insertion wizard form

Feb 25, 2014 9:22 AM

Tags: #drop #cs3 #down #menu #form #insertion #record #wizard

I created a Recordset with a list of states in the US. I then started created a form using Record Insertion Form Wizard. In the form fields, I selected StateID (this is what it is called in my database) and label it "state" and display as "menu" was selected and submit as text. I selected menu properties and populated munu items from database.

 

Recordset: R_states

Get labels from : State_Name

Get values from : State _name

Select value equal to:I left this blank

 

I created form and tested the form. Only the first state in the menu drop down showed up.

 

How do I fix this?

 

Thank you.

 
Replies
  • Currently Being Moderated
    Feb 25, 2014 10:00 AM   in reply to okolawol

    We would need to see the page code to answer that. Sounds like you're missing the loop to populate the menu.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 10:01 AM   in reply to okolawol

    You will have to use a do/while loop on the select list <option></option> tag to retreive all the listed states in your database field State_Name.

     

    Example php code below based on database information provided.

     

     

    <?php do { ?>

     

    <option value="<?php echo $row_R_states['State_Name']; ?>"><?php echo $row_R_states['State_Name']; ?></option>

     

    <?php } while ($row_R_states = mysql_fetch_assoc($R_states)); ?>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 11:14 AM   in reply to okolawol

    It already looks like you have the correct code:

     

     

    do {  ?>

            <option value="<?php echo $row_qState['State_Name']?>"><?php echo $row_qState['State_Name']?></option>

            <?php

    } while ($row_qState = mysql_fetch_assoc($qState));

     

     

     

    Is the 'Type of cuisine' select list being populated correctly?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 11:29 AM   in reply to okolawol

    okolawol wrote:

     

    type of cuisine is also just showing the first item.

     

    I can't see anything wrong with your sql queries or your do/while loops which wrap the <option></option> tags.

     

    The queries are obviously getting the first data entry but nothing else....why is the question.

     

     

    Have you removed the queries from the page and applied them again. I don't use the DW server behaviours any longer but seem to remember having do do this on several ocassions.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 11:43 AM   in reply to osgood_

    I can tell you there is nothing wrong with your sql queries or php code. I've tested the form locally on my server and it works just fine, both the 'State' and 'Cuisine' list are returned in the <option> tags....as I would expect.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 12:07 PM   in reply to okolawol

    okolawol wrote:

     

    So the form allows you to select any other state and cuisine apart from Alaska and Afgan?

    Well I dont have Alaska and Afgan in my list of course - just some county names in the UK and a few different cuisine types BUT yes the drop select menu allows me to select anything in the list, which has been populated from the database fields State_Name and CuisineName

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 12:53 PM   in reply to okolawol

    okolawol wrote:

     

    Is your database setup like this? Maybe there is an issue with my state table. You were able to create a table with some country names and cuisines just like I did. Please take a look.

     

    Looks identical to the set up I used.....so I have no idea why yours is not working.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 1:00 PM   in reply to okolawol

    okolawol wrote:

     

    Thank you.

     

    What is puzzling me is that you say the first State_Name and first CuisineName are being returned from the database into the first <option></option> tag but even though you have a correct do/while loop around the <option></option> tag the rest of the State_Names and CuisineNames are not being echoed out.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 2:54 PM   in reply to okolawol

    Is that happening on insert or update? That message is telling you that there is no parent row id for the corresponding child row you are modifying. It also says you have cascading delete update enabled. Unless you are very familiar with the pitfalls of this, I would not recommend it.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 3:16 PM   in reply to okolawol

    >This is happening on insert from the form.

    >StateID is a secondary key in the restaurant registration table.

     

    A secondary key or a foreign key?

     

     

     

    When I created the relationship,  I have both on delete and on update set to cascade.

     

    Right, do you understand exactly what that does and problems associated with it?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 3:24 PM   in reply to bregent

            <option value="<?php echo $row_qState['State_Name']?>"><?php echo $row_qState['State_Name']?>

     

    Your table needs to be populated with the StateID - here your list is only referencing the State_Name - which is probably why the insert is failing,

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 3:42 PM   in reply to okolawol

    >I meant to say foreign key in the restaurant registration table.

     

    Right, but as I stated in my last post, it looks like you are trying to insert a state name in an Int(2) field. Your recordset must retrieve the state id, and you must populate the drop down menu value with that id.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 4:22 PM   in reply to okolawol

    Actually, you want to select both the name and id.

     

    "SELECT StateID, State_Name FROM state_tbl ORDER BY State_Name ASC";

     

    You then populate the menu value with State_ID, and the menu display with State_Name. That way, the visitor will see the state name, but the state id will be passed by the form into the insert script.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2014 4:36 PM   in reply to okolawol

    >also, to answer your question about my understanding, if a record is deleted, what are the repercusions associated with that.

     

     

    Foreign keys are intended to enforce referential integrity, That is, the DBMS won't let you insert a row into the registration table unless that row's state column contains a state that is already present in the state table. In addition, you can't delete a state from the state table if the registration table has rows that contain that state - unless you have enabled cascade deletes!

     

    Let's say you have a state NJ and have 1000 rows in the registration table with that state id. If you delete NJ from the state table, all 1000 rows in the registration table will get deleted. Is that what you want to happen?  In reality, it's something you probably would never want. In some cases it might be useful, but it's usually triggered by an accident. Someone accidently deletes a single row, and then a huge chunk of data gets deleted. If you really wanted to delete all rows in the registration for NJ, do it manually. Delete those rows first, then delete NJ from the State table - it's much safer.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points