Hello everyone, I am trying to retrieve some data from PostgreSQL using jQuery and PHP. I should be able to enter a date as input -e.g, as 2010-08-09 and retrieve all the data that is dated August 9th- however, when I execute my javascript, all I get as an output is this:
"; echo "
".$rows." -by the way, misc.sp_archive is the sql table, timestamp is the date element of table-
"; } ?>
My code is as below
Javascript Part
<head>
<style type="text/css">
#age{
display: none;
line-height: 0px;
font-size: 20px;
}
</style>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript">
function getDates(value){
$.post("file.php",{myDate:value},function(data) {
$("#results").html(data);
});}
</script>
</head>
<body>
<input type="text" onkeyup="getDates(this.value)"/>
<br>
<div id="results"></div>
</body>
</html>
and here is the php code
<?php
$myDate=$_POST['myDate'];
$connection = pg_connect("dbname=mydbname user=tehusername host=localhost port=5432");
$myresult = pg_query($connection, "SELECT * FROM misc.sp_archive WHERE misc.sp_archive.timestamp BETWEEN '$myDate' AND '2010-08-12' LIMIT 15");
while($rows = pg_fetch_all($myresult))
{
echo "<pre>";
echo "<div>".$rows['misc.sp_archive.timestamp']."</div>";
}
?>
How can I get this code to work ? I double checked everything and it looks fine as far as I know. I also checked whether I am connected to the database during the code execution and I am. I would be grateful for any help. Thanks.