Hello Everybody,
i m new one in php/mysql, i created my database with the name of air_data, and in table i created 4 fields, in which one is "date", in every row i have different dates, now i trying to find out those "date" records for which i m searching
for example:
in my search.php
i have two text fields "from date" and "to date" whenever i click on the search button it goes to the next page "selected.php" and there i wana to see my records according to the list of dates.

2010-05-10
2010-05-11
2010-05-12
2010-05-13

if searching from_date(2010-05-11) to to_date(2010-05-13) records the result should be in rows like...
2010-05-11
2010-05-12
2010-05-13

***Bundle of thnx in advance***

You should write following query in you selected.php page.

select * from table_name where date between '{$_REQUEST['from_date']}' and '{$_REQUEST['to_date']}'

>>

You should write following query in you selected.php page.
>>>

>>>>select * from table_name where date between '{$_REQUEST['from_date']}' >>>>>and '{$_REQUEST['to_date']}'
>>>>>>

Lot of thnx for replying...

if u dont mind can i ask that what will be the code to display the records as a report after compiling the code, because when i run only the above query it compiles safely but there is no record seems.

Post your code of selected.php script

Member Avatar for rajarajan2017

Below is the sample to connect databse, retrieving table datas and display as a report. Please go thru and replace your query here and display output as you need

<html> 
<head> 
<basefont face="Arial"> 
</head> 
<body> 

<?php 

// set database server access variables: 
$host = "localhost"; 
$user = "root"; 
$pass = ""; 
$db = "testdb"; 

// open connection 
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 

// select database 
mysql_select_db($db) or die ("Unable to select database!"); 

// create query 
$query = "SELECT * FROM symbols"; 

// execute query 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

// see if any rows were returned 
if (mysql_num_rows($result) > 0) { 
    // yes 
    // print them one after another 
    echo "<table cellpadding=10 border=1>"; 
    while($row = mysql_fetch_row($result)) { 
        echo "<tr>"; 
        echo "<td>".$row[0]."</td>"; 
        echo "<td>" . $row[1]."</td>"; 
        echo "<td>".$row[2]."</td>"; 
        echo "</tr>"; 
    } 
    echo "</table>"; 
} 
else { 
    // no 
    // print status message 
    echo "No rows found!"; 
} 

// free result set memory 
mysql_free_result($result); 

// close connection 
mysql_close($connection); 

?> 

</body> 
</html>

Below is the sample to connect databse, retrieving table datas and display as a report. Please go thru and replace your query here and display output as you need

<html> 
<head> 
<basefont face="Arial"> 
</head> 
<body> 

<?php 

// set database server access variables: 
$host = "localhost"; 
$user = "root"; 
$pass = ""; 
$db = "testdb"; 

// open connection 
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 

// select database 
mysql_select_db($db) or die ("Unable to select database!"); 

// create query 
$query = "SELECT * FROM symbols"; 

// execute query 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

// see if any rows were returned 
if (mysql_num_rows($result) > 0) { 
    // yes 
    // print them one after another 
    echo "<table cellpadding=10 border=1>"; 
    while($row = mysql_fetch_row($result)) { 
        echo "<tr>"; 
        echo "<td>".$row[0]."</td>"; 
        echo "<td>" . $row[1]."</td>"; 
        echo "<td>".$row[2]."</td>"; 
        echo "</tr>"; 
    } 
    echo "</table>"; 
} 
else { 
    // no 
    // print status message 
    echo "No rows found!"; 
} 

// free result set memory 
mysql_free_result($result); 

// close connection 
mysql_close($connection); 

?> 

</body> 
</html>

**************************************************************

Thats Gre@t Job............
..............Have a nice time with u
so much thanks................

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.