I want to generate a report of certain criteria from my website, The website is an an web application used to save breakdown time and details of the machines in a company. Here i want to generate an report based on breakdown type, breakdown machine , break down attended by etc.,.
So i have created an search form to do so and i have used dynamic dropdown menu from my database and successfully created a code that will select multiple values as well like (Under Machine- we can select machine names like machine1,machine2 and so on) and after i press search it shows only the result for the last selected value but i want to show the results(details) of all the selected values.
**form.php**
<?php
//index.php
include('database_connection.php');
$country = '';
$query = "
SELECT type FROM reporttype
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$country .= '<option value="'.$row["type"].'">'.$row["type"].'</option>';
}
?>
<div class="container">
<h2 align="center"></h2><br /><br />
<form method="post" id="insert_data" action="insert.php">
<label class="col-md-2 bdlabel">Break Down</label>
<select name="country" id="country" class="col-md-10 form-control action">
<option value="">Choose a Category</option>
<?php echo $country; ?>
</select>
<br />
<select name="city" id="city" multiple class="form-control">
</select>
<br />
<input type="hidden" name="hidden_city" id="hidden_city" />
<div class="form-group">
<div class="datepic">
<label class="col-md-2 bdlabel bdfrom">From</label>
<input type="date" name="bdfrom" class="col-md-4">
</div>
<div class="datepic1">
<label class="col-md-2 bdlabel bdto">To</label>
<input type="date" name="bdto" class="col-md-4">
</div>
</div>
<br/>
<input type="submit" name="search" id="action" class="btn btn-info"
value="Search" />
</form>
</div>
<script>
// JavaScript Document
$(document).ready(function(){
$('#city').lwMultiSelect();
$('.action').change(function(){
if($(this).val() != '')
{
var action = $(this).attr("id");
var query = $(this).val();
var result = '';
if(action == 'country')
{
result = 'city';
}
$.ajax({
url:'fetch.php',
method:"POST",
data:{action:action, query:query},
success:function(data)
{
$('#'+result).html(data);
if(result == 'city')
{
$('#city').data('plugin_lwMultiSelect').updateList();
}
}
})
}
});
});
</script>
insert.php
<?php
//insert.php
include('db.php');
if(isset($_POST['search']))
$city=$_POST['city'];
$from=$_POST['bdfrom'];
$to=$_GET['bdto'];
{
$raw_results = mysql_query("SELECT * FROM breakdownentry
WHERE bdmwc in ('$city') || bdmname in ('$city') || bdaname in ('$city') ")
or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following
while($results = mysql_fetch_array($raw_results)){
echo "<p>".$results['bdmwc']."</p>";
}
}
else{
echo "No results";
}
}
?>
What i want to show is wire drawing and nail but only nail value is been shown.