hi friends,

In my project, want to display data from Mysql between two date. Date was given by user only, according to that it take info from database,


And important things is display the retrieve information through table,

My Html coding :

<body>
<form method="post" action="reportviewinfo.php">
<label>From Time : </label><input type="text" name="from" /><br/><br/>
<label>To Time   : </label><input type="text" name="to" /><br/><br/>
<input type="submit" name="submit" value="Submit" />
</form>
</body>

Php code

<?php
include("config.php");




if(isset($submit))
{
	
$from = $_POST['$from'];
$to = $_POST['$to'];
$submit = $_POST['$submit'];

$sql = "select * from report where dat >= '$fromtime' and dat <= '$totime' ";

$result= mysql_query($sql);

echo "<table> <table>
        <tr>
            <td>
                Date</td>
            <td>
                S.No</td>
            <td>
                Circuit Name</td>
            <td>
                Section</td>
            <td>
                Time-IN</td>
            <td>
                Time-OUT</td>
            <td>
                Nature of Failure</td>
            <td>
                Cause of Failure</td>
            <td>
                Attended By</td>
            <td>
                Remark</td>
            <td>
                Failure Duration</td>
            <td>
                Repercussions</td>
        </tr>" ;
		
		while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
		{
			
		echo "<tr><td> {$row['dat']}</td> <td> {$row['sno']}</td> <td> {$row['name']}</td> <td> {$row['section']}</td> <td> {$row['timein']}</td> <td> {$row['timeout']}</td> <td> {$row['nature']}</td> <td> {$row['cause']}</td> <td> {$row['attended']}</td> <td> {$row['remark']}</td> <td> {$row['duration']}</td> <td> {$row['repercussion']}</td> </tr> <br/> " ;
		
		
		}
		
		
		echo "</table>" ;

It not working, plz help me....

Member Avatar for TechySafi

Instead of this

if(isset($submit))
{
 
$from = $_POST['$from'];
$to = $_POST['$to'];
$submit = $_POST['$submit'];
 
$sql = "select * from report where dat >= '$fromtime' and dat <= '$totime' ";

Try this...

if(isset($_POST['submit']))
{
 
$from = $_POST['from'];
$to = $_POST['to'];
 
$sql = "select * from report where dat >= '$from' and dat <= '$to'";

See what happens, if you still get errors, show me what kinda error it is.

Instead of this

if(isset($submit))
{
 
$from = $_POST['$from'];
$to = $_POST['$to'];
$submit = $_POST['$submit'];
 
$sql = "select * from report where dat >= '$fromtime' and dat <= '$totime' ";

Try this...

if(isset($_POST['submit']))
{
 
$from = $_POST['from'];
$to = $_POST['to'];
 
$sql = "select * from report where dat >= '$from' and dat <= '$to'";

See what happens, if you still get errors, show me what kinda error it is.

I try it, it get error again,

<?php 
$from = $_POST['from'];
$to = $_POST['to'];

if(isset($submit))
{
$sql = "select * from report where dat >= '$fromtime' and dat <= '$totime' ";

}
Notice: Undefined index: $from  on line 15

Notice: Undefined index: $to   on line 16
Member Avatar for diafol
$from = $_POST['from'];
$to = $_POST['to'];
 
if(isset($submit))
{
$sql = "select * from report where dat >= '$from' and dat <= '$to' ";
}
Member Avatar for TechySafi

Try ardav's example...

$from = $_POST['from'];
$to = $_POST['to'];
 
if(isset($submit))
{
$sql = "select * from report where dat >= '$from' and dat <= '$to' ";
}

Hi everybody,

I clear my error, thanks to all :)

Member Avatar for diafol

Mark as solved please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.