I am new to web development. I am trying to implement a database-driven web server using Apache+PHP+SQLite. Using the post method, I try to pass the input values on the html page to the web server as an SQL query to retrieve data inside the database.
Problem description: Let's say there is a table (named my_table) in my database, having 3 columns, a1, a2 and a3. In the php file, there are 3 input values specified by the end-user, say $v1, $v2 and $v3. The values of $v1, $v2 and $v3 will be matched with patterns in a1, a2 and a3 so that the matched data rows will be retrieved. $v1, $v2 or $v3 can be an empty string, depending on the queries by the user. Formally speaking, if $v1='', $v2='' and $v3='', all of the data in my_table will be retrieved; if $v1='v1_value', $v2='' and $v3='', the data where column a1 has pattern v1_value will be retrieved.
My HTML form tag
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table>
<tr><td>Item1: </td><td><input type="text" name="v1"></td></tr>
<tr><td>Item2: </td><td><input type="text" name="v2"></td></tr>
<tr><td>Item3: </td><td><input type="text" name="v3"></td>
</table>
<input type="submit", name="submit" value="Submit">
</form>
My PHP code
$v1 = $_POST['v1'];
$v2 = $_POST['v2'];
$v3 = $_POST['v3'];
And I am stuck at here...
$query = "SELECT * FROM my_table WHERE <A_PROPER_CONDITION_STATEMENT>"
That is, how to have a query to retrieve data as I want.
Hope I describe clearly. Thanks for help.