SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Generating MySQL query based on user's input using HTML Form

    Hi,

    I am trying to make a HTML web form which will be looking something like this:



    Now, my question is, here I've shown three companies names have been entered. What if user wants to update rate for two companies instead of three?

    How should I write query which can dynamically add variable/s inside its statement?

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,334
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by media9 View Post
    How should I write query which can dynamically add variable/s inside its statement?
    the relevant part of the query is...
    Code:
     WHERE companyname IN ( list of company names )
    the rests of your solution depends on whichever application language you're using -- asp, php, whatever

    please re-ask the question in the appropriate forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    the relevant part of the query is...
    Code:
     WHERE companyname IN ( list of company names )

    "list of company names" - do I need to pass an array here?

    Yes, using PHP.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    list of company names would be a comma-seperated list of quote-encapsulated values. use of the implode() function would be advised.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi StarLion, thanks for your suggestion. I got it done


Bookmarks

Posting Permissions

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