0

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***

3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by ismael ahm@d
0

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

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

>>

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.

0

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>
0

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................

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.