php - Input Values and Select Return Data -


I am trying to create a webpage where the user can submit information that they know and the information they want For those whom they want to return, for example, if they know the ID number for their submission, then they can enter it and ask the name of the number and the name of the product for the returned values.

The information that is being retrieved is stored in a MySQL database, and the HTML page is placed along with a selection menu, text box and checkbox (so that users can select the name or other information

  & lt; table & gt; & lt; tr & gt; & lt; form name = "input" method = "post" action = " Next Php ">  Flossel ID: 
Select name =" Flossel_ID "> Option disabled =" Disabled "selection = "Selected" & gt; Select ... & lt; / option & gt; & lt ;? php $ link = mysqli_connect ("localhost", "user", "pass", "db"); $ query = " Select the different identification ID from the table "; $ result = mysqli_query ($ link, $ query); while ($ line = mysqli_fetch_array ($ result)) {$ id = $ line ['id']; echo '& lt; option value = \ "$ Id \" & gt; $ id & lt; / option & gt; "}} Mysqli_close ($ link);? & Gt; & lt; / selection & gt; & lt; / td & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "120" & gt; Date: & lt; Input type = "article" name = "date" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "120" & gt; Group: & lt; Input type = "article" name = "group" /> & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "120" & gt; Input type = "checkbox" name = "option []" value = "id" & gt; Id & lt; / Input & gt; & Lt; / Td> & Lt; Td width = "120" & gt; Input type = "checkbox" name = "option []" value = "name" & gt; Name & lt; / Input & gt; & Lt; / Td> & Lt; Td width = "120" & gt; Input type = "checkbox" name = "option []" value = "date" & gt; Date & lt; / Input & gt; & Lt; / Td> & Lt; Td width = "120" & gt; Input type = "checkbox" name = "option []" value = "group" & gt; Group & lt; / Input & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt;

I have only php so far:

  $ id = $ _POST ['id']; $ Name = $ _POST ['name']; $ Date = $ _POST ['date']; $ Group = $ _POST ['group'];   

How do I create a MySQL query that select

  [check box] [information field] from the table = [registered by user Information]   

?

Thank you!

You can enhance the query:

  $ fields = Array ('id' = & gt; 'id', 'name' = & gt; 'name', 'date' = & gt; 'date', 'group' = & gt; 'group',); $ Query = 'SELECT'; // Optional fields to display can be $ comma = '' here; // And if they do, start with $ comma = ','; $ Where = array (); Foreign currency ($ field as $ field = & gt; $ mysql) {// Here we have '$' id, our mailing field and // $ mysql, say, 'id' - MySQL field name . // Check whether the option ['id'] is set. If so, then we should get the _POST [ID] field and check its contents against the "id" field in DB. If (in_array ($ post, $ _POST ['options'])) {$ query. = "$ Comma $ mysql"; $ Comma = ','; // Add WHERE bet $ where [] = "$ mysql = '" mysql_real_escape_string ($ _ POST [$ post]). "'"; }} // $ comma, the separator between the options field, is also doubled in check // to see if we have the status or not. // Another possibility, "If (empty ($ where) '" (' '== $ coma) will die ("You have to select at least one checkbox!"); $ Query = 'WHERE from table'; // Build Status $ query = '(' .implode ('and', $ where). ')'; // Other conditions can go here (like "AND record_valid = 1") $ query. = ';';    

Comments