I am unable to figure out how to enter data into a form and then query

  • eljay
    Asked on April 9, 2020 at 8:02 PM

    I am unable to figure out how to enter data into a form and then query mysql with the form entries and output the results:

    e.g.

    table_name=work

    columns include but are not limited to labor, day, hours, etc.

    form includes entry for 1. Drivers: trucks, cars, fork lifts; 2. Days: mon, tues, wed... ; Hours: day, afternoons, nights.

    If I make entries into the form 1. trucks, 2: wed, 3: day then my query resembles SELECT * FROM work WHERE drivers = trucks AND days = mon AND hours = days then I want to enter the form data into a mysqli query and output which drivers drove a truck on the day shift on Monday.

    Been pulling my hair out trying to get this to work.

  • Jed_C
    Replied on April 9, 2020 at 10:43 PM

    Provided that your table name is "work", try the syntax below and let us know if that works.

    Note: without the apostrophe, you are assigning a value instead of calling a string.

    SELECT * FROM work WHERE Drivers='trucks' AND Days='mon' AND Hours='days';