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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    easy way to select a field from sql using PHP

    Is there an easy way to select a field from a combox(select field) from MYSQL using PHP?
    It can be in Ajax.

    Coz' i want to create an edit form, so when it loads, it selects the current index from my sql database.

    PHP Code:
    My current idea is to create a variable for each index for example:
    <select>
    <option <?php echo $select1?> value = 1>Choice 1</option>
    <option <?php echo $select2?> value = 2>Choice 2</option>
    <option <?php echo $select3?> value = 3>Choice 3</option>
    </select>
    But what if I looped the <select> for date purposes.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Coz' i want to create an edit form, so when it loads, it selects the current index from my sql database.
    Make an if condition inside the loop to add an extra attribute to the required option, like selected="selected"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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