javascript - Create SQL sentece according to users input MySQL -


What I want to do is this:

First there is a form in which for example 5 Input:

  Name: Career: Experience: City: Attribute:   

What do I need to do is a sql sentence According to the fields that are filled if only 2 fields were filled, then create a SQL with only those fields I have no idea, which would make an SQL statement for every possible possibility. In addition to the area how to do that is a very comprehensive work. I have read that I can use store procedures, but I do not know how I will do it. Please help me!


I'm sorry that if I did not elaborate the question

here I have a separate table in the mysql database

  • The person <
  • Personal
  • li experience_description
  • experience_to_date
  • experience_to_date

    All of these tables are related to person by foreign_key (person_id)

    Then I have a page where the user has 6 al The different inputs are:

    • Name:
    • last_name:
    • Courses:
    • Experience: (This is the search status and
    • Antiquity: (All person_experience needs to get sumatory)

      User

        

      D> Select a.person_id, b.name, c.last_name, d.courses, f.experience, person to g.antiquity, ('sql sentence' where name is ("SQL statement" where "SQL statement" like "SQL statement" ("SQL statement" where "%%" by course "PERSON_ID" by course), (Where 'SQL statement' "%%" by type "%%" or EXPERIENCE_DESCRIPTION by group "PERSON_ID"), ('SQATORY' for all the person's experience of SQL SENTECE 'WHERE' (TO_DATE - FROM_DATE) / 365 '& gt; = 0 (this The zero will change the user fills the input then the antiquity I) Group by PERSON_ID) Where a.person_id = b .person_id and c.person_id = b.person_id and d.person_id = c.person_id and f.person_id = d.person_id and g.person_id = f.person_id

      And if user fill in any field I put the value between '% value%', in this way I get the result, and I get results with this SQL sentence but the problem is Is that if a person has no experience or is not a result which has not been shown in it, therefore I am There is a need like, as I said in the first place, find the database in the database according to the input filled by the user.

      For example, if the user fills:

      • Condensed, experience: Search for all the person with that person and that experience.
      • Name: Search for all the people, even if they do not have a train or course or experience with that name.

        PS: In every attempt to create a SQL intake for 64, sql will be the result of rites and I am not thinking about doing this!

        Thanks for all the help in advance

        Here's something that can help Can:

          $ sql = array (); // Start the empty table as the $ key in the form of data foreach (array ("name", "careers", "experience", "city", "attribute") {// repeat all form controls (if empty ($ value = trim ($ _ POST [$ key])) {// Form input is full, so we add it to the data array (with proper escape) $ sql ["` ". $ key "//"] = "" .mysqli_real_escape_string ($ value). "'" "}} If (count ($ sql)) {// only if the user had provided some data then the last SQL statement $ sql =" INSERT IN 'TALK (`.memplode (", ", array_keys ($ sql))." Value ("// for example (` name`, `career ') .Iplplod (", ", array_values ​​($ sql) }). ") For example ('foo', 'bar')} and {// no information provided}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -