Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    code for omitting not selected mysql driven drop down menus

    Hi I have an update page with a form which contains 7 drop down menus and 2 text fields, all being populated by a select command on a mysql database, the whole page works fine with data coming and going back into the database. However, I can not work out the following. This is the code for one of the drop down menus, I might be better in the php forum but thought I would start here.

    How to stop all the drop down fields being populated?

    I have a couple of solutions

    1. To carry out a function in php to omit the fields which contain my default of 0 which will mean they have not been updated.

    or

    2. To insert an html "selected" command into the php echos,

    The problem is that I am not experienced enough to program either, if someone is able to help it would be very much appreciated.

    PHP Code:

    <?php echo  $typedescrip ['type_description']; ?>
        <select name="type_id">
        <?php 
            $type_set 
    findtype();
            
    $typelist mysql_fetch_assoc ($type_set);
        
    ?>
        <?php 
        
    do { 
        
    ?>   <option value="<?php echo $typelist ['type_id']; ?>" ><?php echo $typelist ['type_description'], $typelist ['type_id']; ?></option>
        <?php 
        
    } while ($typelist mysql_fetch_assoc ($type_set)); 
        
    ?></select>

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    I don't see any mySQL code here? Can you show your query/queries? It sounds more like you're having a PHP code design issue, unless your actual mySQL isn't working?

    What do you mean by "How to stop all the drop down fields being populated?"?

  • #3
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    659
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Tis a PHP related issue; moved accordingly.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •