Okay then. Let's see what we have here.
I think you should be able to solve it from here.
Here's the import.sql file I have exported
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
;
;
;
;
CREATE TABLE IF NOT EXISTS `import` (
`id` int(11) NOT NULL,
`srno` int(11) NOT NULL,
`date` varchar(64) NOT NULL,
`mobno` int(11) NOT NULL,
`city` varchar(64) NOT NULL,
`state` varchar(64) NOT NULL,
`type` varchar(64) NOT NULL,
`telecaller` varchar(64) NOT NULL,
`date1` varchar(64) NOT NULL,
`time` varchar(64) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `import` (`id`, `srno`, `date`, `mobno`, `city`, `state`, `type`, `telecaller`, `date1`, `time`) VALUES
(0, 11, '27-Jul-2012', 2147483647, '', 'Maharashtra', 'ADMIN', 'Sitara', '7-Aug-2012', '12:48.PM'),
(0, 12, '27-Jul-2012', 2147483647, '', 'Andhra Pradesh', 'ADMIN', 'Sitara\r', '7-Aug-2012', '12:49.PM'),
(0, 13, '27-Jul-2012', 2147483647, '', 'Kerala', 'ADMIN', 'Snehal\r', '7-Aug-2012', '12:49.PM'),
(0, 14, '27-Jul-2012', 2147483647, '', 'Maharashtra', 'ADMIN', 'Sitara\r', '7-Aug-2012', '12:49.PM'),
(0, 15, '27-Jul-2012', 2147483647, '', 'Gujrat', 'ADMIN', 'Sitara', '7-Aug-2012', '12:40.PM'),
(0, 16, '27-Jul-2012', 2147483647, '', 'Maharashtra', 'ADMIN', 'Anuja\r', '7-Aug-2012', '12:49.PM'),
(0, 17, '27-Jul-2012', 2147483647, '', 'West Bengal', 'ADMIN', 'Anuja', '7-Aug-2012', '12:39.PM'),
(0, 18, '27-Jul-2012', 2147483647, '', 'Maharashtra', 'ADMIN', 'Anuja\r', '7-Aug-2012', '12:49.PM'),
(0, 19, '27-Jul-2012', 2147483647, '', 'Karnataka', 'ADMIN', 'Anuja\r', '7-Aug-2012', '12:49.PM'),
(0, 20, '27-Jul-2012', 2147483647, '', 'Maharashtra', 'ADMIN', 'Anuja\r', '7-Aug-2012', '12:49.PM');
;
;
;
Here's the test php file I've been using (sqlTest.php):
<?php
$server = 'localhost';
$user = '** YOUR USERNAME HERE **';
$password = '** YOUR PASSWORD HERE **';
$dbLink = mysql_connect($server, $user, $password);
if (!$dbLink)
die('Can\'t establish a connection to the database: ' . mysql_error());
$dbSelected = mysql_select_db('test', $dbLink);
if (!$dbSelected) die ('We\'re connected, but can\'t use the table: ' . mysql_error());
echo "<form action='sqlTest.php'>";
echo "<select name='test[]' multiple='multiple'>";
$sql = "SELECT DISTINCT time FROM import ORDER BY time asc";
$res1=mysql_query($sql);
while($row= mysql_fetch_array($res1))
{
echo "<option value='". $row['time'] . "'>".$row['time']."</option>";
}
echo "</select>";
echo"<input type='submit' value='submit'/>";
echo"</form>";
if (isset($_GET['test']))
{
$i = 0;
foreach ($_GET['test'] as $selectedOption)
{
$options[$i++] = $selectedOption;
}
$sql = "select DISTINCT date,mobno,city,state,type,telecaller,time FROM import WHERE time IN(";
$num = count($options);
for ($i=0; $i<$num-1; $i++)
{
$sql .= "'".$options[$i]."', ";
}
$sql .= "'".$options[$i]."')";
$sql .= "OR date1='01/01/0000'";
echo $sql . "<br>";
$result = mysql_query($sql);
print "<div id='print'>";
print "<center>List of Mobile Numbers for Date <font color='#FF00FF'>";
print "<u>01/01/000</u></font> or Time <font color='#FF00FF'>";
print "<u>12:49.PM</u></font> <center> <br/>";
print "<table border='1' cellspacing='5' cellpadding='12'>";
print "<tr bgcolor='#82CAFF'>";
print "<th>Sr.No</th>";
print "<th>Date</th>";
print "<th>Mobile No</th>";
print "<th>City</th>";
print "<th>State</th>";
print "<th>Type</th>";
print "<th>CIExe.</th>";
print "<th>Time</th>";
print "</tr>";
$srno1=0;
while($row=mysql_fetch_array($result))
{
$srno1=$srno1+1;
print"<tr>";
print"<td>" .$srno1. "</td>";
print"<td>" . $row['date'] . "</td>";
print"<td>" . $row['mobno'] . "</td>";
print"<td>" . $row['city'] . "</td>";
print"<td>" . $row['state'] . "</td>";
print"<td>" . $row['type'] . "</td>";
print"<td>" . $row['telecaller'] . "</td>";
print"<td>" . $row['time'] . "</td>";
print"</tr>";
}
print"</table>";
print"</div>";
echo"<br/>";
}
?>
Here's the output when opened for the first time
<html>
<head>
</head>
<body>
<form action="sqlTest.php">
<select name="test[]" multiple="multiple">
<option value="12:39.PM">12:39.PM</option>
<option value="12:40.PM">12:40.PM</option>
<option value="12:48.PM">12:48.PM</option>
<option value="12:49.PM">12:49.PM</option>
</select>
<input type="submit" value="submit">
</form>
</body>
</html>
Here's the output when the first 3 options are selected:
select DISTINCT date,mobno,city,state,type,telecaller,time FROM import WHERE time IN('12:39.PM', '12:40.PM', '12:48.PM')OR date1='01/01/0000'
List of Mobile Numbers for Date 01/01/000 or Time 12:49.PM
Sr.No | Date | Mobile No | City | State | Type
| CIExe.
| Time
|
1
| 27-Jul-2012
| 2147483647
| | Maharashtra
| ADMIN
| Sitara
| 12:48.PM
|
2
| 27-Jul-2012
| 2147483647
| | Gujrat
| ADMIN
| Sitara
| 12:40.PM
|
3
| 27-Jul-2012
| 2147483647
| | West Bengal
| ADMIN
| Anuja
| 12:39.PM
|