Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:40:45+00:00 2026-06-07T07:40:45+00:00

I’m trying to create a webpage where the user can submit information that they

  • 0

I’m trying to create a webpage where the user can submit information that they know and select information they’d like returned. For example, if they know the ID number for their submission, they can enter it and ask for the returned values to be the ID number and product name.

The information that’s being retrieved is stored in a MySQL database, and the html page is laid out with a select menu, text boxes, and checkboxes (so that the user can select a name or enter other information, and then use the checkboxes to select the other information they want returned).

Here’s the relevant html:

<table><tr>
<form name="input" method="post" action="next.php">
<td width="120">Flowcell ID:<br />
<select name = "Flowcell_ID">
<option disabled="disabled" selected="selected">
Select...
</option>
<?php
$link = mysqli_connect("localhost","user","pass","db");
$query = "SELECT DISTINCT ID FROM table";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result)){
$id = $row['ID'];
echo "<option value=\"$id\">$id</option>";
}
mysqli_close($link);
?>
</select></td>
</tr><tr>
<td width="120">Name:<input type="text" name="Name" /></td>
</tr><tr>
<td width="120">Date:<input type="text" name="Date" /></td>
</tr><tr>
<td width="120">Group:<input type="text" name="Group" /></td>
</tr><tr>
<td width="120"><input type="checkbox" name="options[]" value="ID">ID</input></td>
<td width="120"><input type="checkbox" name="options[]" value="Name">Name</input></td>
<td width="120"><input type="checkbox" name="options[]" value="Date">Date</input></td>
<td width="120"><input type="checkbox" name="options[]" value="Group">Group</input></td>
</tr></table>

The only php I have so far is:

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

How would I produce a MySQL query that looks like

SELECT [checked checkboxes] FROM table WHERE [information field] = [user-entered information]

?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:40:47+00:00Added an answer on June 7, 2026 at 7:40 am

    You can build the query incrementally:

    $fields = array(
       'ID'   => 'id',
       'Name' => 'name',
       'Date' => 'date',
       'Group' => 'group',
    );
    
    $query = 'SELECT';  // Optional fields to be displayed may go here
    $comma = ' ';       // and if they do, start with $comma = ', ';
    
    $where = array();
    
    foreach($fields as $post => $mysql)
    {
        // here we have $post equal to 'ID', our POST field, and
        // $mysql equal to, say, 'Id' -- the MySQL field name.
        // Check whether options['ID'] is set. If so, we must get
        // the _POST[ID] field and check its contents against "Id" field in DB.
        if (in_array($post, $_POST['options']))
        {
            $query .= "$comma$mysql";
            $comma = ', ';
            // Add WHERE condition
            $where[] = "$mysql = '" . mysql_real_escape_string($_POST[$post]) . "'";
        }
    }
    // $comma, the separator between option fields, also doubles up as a check
    // to see whether we have conditions.
    // another possibility would be, "if (empty($where))"
    if (' ' == $comma)
       die("You must select at least one checkbox!");
    
    $query .= ' FROM table WHERE ';
    // Build WHERE condition
    $query .= '(' . implode(' AND ', $where).')';
    
    // Other conditions may go here (e.g. " AND record_valid = 1 ")
    
    $query .= ';';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I know there's a lot of other questions out there that deal with this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.