I'm new with php.I have written a function fill_data($tagindex) now I want to call filldata(0); Input from a html form is a dropdownlist with AI-Types. I want it work like if i select AI-Type as eg.DTP4 then fill_data(0);fill_data(1);fill_data(2); should be called as result will be displayed accordingly. My question is that how can i do it? Can anybody help??plz.. Below is my so far tried code..
project.php
function fill_data($tagindex)
{
$fromdate=$_POST['fromdate'];
$todate=$_POST['todate'];
$fromtime=$_POST['fromtime'];
$totime=$_POST['totime'];
// Create connection
$conn = mysqli_connect('localhost', 'root', '','test');
// Check connection
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$sql ="SELECT * FROM floattable WHERE TagIndex=$tagindex AND (DateAndTime between '$fromdate .' '. $fromtime' AND '$todate .' '. $totime') ORDER BY DateAndTime ASC;";
$result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
try{
//for IP
if (($tagindex=0)||($tagindex=1)||($tagindex=2)||($tagindex=3)||($tagindex=4)||($tagindex=5)||($tagindex=6)||($tagindex=7)||($tagindex=8)||($tagindex=10)||($tagindex=11)||($tagindex=12)||($tagindex=13)||($tagindex=14)||($tagindex=14)||($tagindex=15)||
($tagindex=16)||($tagindex=17)||($tagindex=18)||($tagindex=19)||($tagindex=20)||($tagindex=21)||($tagindex=22)||($tagindex=23)||($tagindex=24)||($tagindex=25)||($tagindex=26)||($tagindex=27)||($tagindex=28)||($tagindex=29)||($tagindex=30)||($tagindex=31)||($tagindex=32)||
($tagindex=33)||($tagindex=34)||($tagindex=35)||($tagindex=36)||($tagindex=37)||($tagindex=38)||($tagindex=39)||($tagindex=40))
{
// to display output
echo "<table border='1' cellspacing='3' align='centre'>
<tr>
<th>DateAndTime</th>
<th>Millitm</th>
<th>TagIndex</th>
<th>Value</th>
<th>Status</th>
<th>Market</th>
</tr>";
while ($row = mysqli_fetch_array($result))
{
echo " <tr>
<td>".$row['DateAndTime']."</td>
<td>".$row['Millitm']."</td>
<td>".$row['TagIndex']."</td>
<td>".$row['Val']."</td>
<td>".$row['Status']."</td>
<td>".$row['Marker']."</td>
</tr>";
}
echo "</table>";
}
}
catch (Exception $e)
{
echo $e->getmessage();
exit(1);
}
mysqli_close($conn);
}//End-of Fill_data Function
if(isset($_POST["submit"]))
{
$selected = $_POST['AI-Types'];
if('what condition i should write here so that below three calls will be executed')
fill_data(0);
fill_data(1);
fill_data(2);
// FT1,FT2 are the inputs from the dropdownlist in html
//i want it work like if i select FT1 call to fill_data(2); should be executed
//dont think of $currentsheet it is just variable it can be removed
$currentSheet = "FT1";
fill_data(3);
$currentSheet = "FT2";
fill_data(4);
$currentSheet = "FT3";
fill_data(5);
fill_data(6);
$currentSheet = "LT1";
fill_data(7);
$currentSheet = "LT2";
fill_data(8);
fill_data(9);
//
</div>