I have an HTML page that takes multiple input from the useras a numeric code and then displays output in another php page. The data is retrieved from a database table.
my code is not working, can you please help me figure out why?
the php code:
$var1 = "where CODE like '%{$_POST['AGI1']}%'";
$var2 = "where CODE like '%{$_POST['AGI2']}%'";
$var3 = "where CODE like '%{$_POST['AGI3']}%'";
$var4 = "where CODE like '%{$_POST['AGI4']}%'";
$sql = "select * from table $var1" ;
$sql .= "select * from table $var2" ;
$sql .= "select * from table $var3" ;
$sql .= "select * from table $var4" ;
$result = mysqli_query($conn,$sql1, $sql2, $sql3, $sql4);
Thanks in advance, I appreciate all the help. I'm still new to using php so I'm sorry if this is a silly question.
edit:
the code is now the following:
$var1 = "where CODE like '%{$_POST['AGI1']}%' OR CODE like '%{$_POST['AGI2']}%' OR CODE like '%{$_POST['AGI3']}%' OR CODE like '%{$_POST['AGI4']}%' ";
$sql = "select * from proteinpd $var1;";
$result = mysqli_query($conn,$sql);
.
.
.
while($row = mysqli_fetch_array($result)){
it is showing me the result of all the table and not only for the codes I have chosen. Why so?
INPUT FORM:
<form action="output.php" method="POST" >
<table>
<div>
<h2 > AGI </h2>
<p><input name="AGI1"type="text"></p>
<p><input name="AGI2" type="text"></p>
<p><input name="AGI3" type="text"></p>
<p><input name="AGI4" type="text"></p>
<p> <input type="Submit" value="OK"></p>
</div>
</form>
Database table structure: