Jump to content

DateRange to Post


hkalan2007

Recommended Posts

Hello,

 

I have 2 jquery date pickers (start and end date) to pull the daterange mysql data,that will POST data on the webpage from mysql table.

 

I can not seem to get the PHP to work right.

 

The table is very simple.

 

Unit ID  | DATE | Time | Power | Volt | Current|

 

Data is entered every hour (24 hours a day)

 

The jquery date pickers select the date range on the website to post the report.php, and I wish to display the Date,Time,Power,Volt,Current in that range in a straight table on the wen page. You can see the how I want it on the website http://www.pvmonitor.000a.biz/sw-report.php This will help you understand my meaning better.

 

Here is the report.php... Please let me know where I am going wrong.

 

<?
$start = (isset($_POST['start'])) ? date("Y-m-d",strtotime($_POST['start'])) : date("Y-m-d");
$end   = (isset($_POST['end'])) ? date("Y-m-d",strtotime($_POST['end'])) : date("Y-m-d");
$con = mysql_connect('localhost', 'root', 'XXXXXX'); 
if (!$con) 
  { 
  die('Could not connect: ' . mysql_error()); 
  } 

mysql_select_db("inverters", $con); 

$sql='select * FROM feed AS genreport '  
.'BETWEEN [start] and [end]'; 

$res = mysql_query($sql); 
while ($row = mysql_fetch_assoc($res)) 
echo $row['genreport']; 
echo "<table border='1'> 
<tr> 
<th>Date</th> 
<th>Hour</th> 
<th>Power</th> 
<th>Volt</th> 
<th>Current</th> 
</tr>"; 

while($row = mysql_fetch_array($result)) 
  { 
  echo "<tr>"; 
  echo "<td>" . $row['Date'] . "</td>"; 
  echo "<td>" . $row['Time'] . "</td>"; 
  echo "<td>" . $row['Power'] . "</td>"; 
  echo "<td>" . $row['Volt'] . "</td>"; 
  echo "<td>" . $row['Current'] . "</td>"; 
  echo "</tr>"; 
  } 
echo "</table>"; 

mysql_close($con); 
?>

 

 

Thanks,

 

Alan

Link to comment
https://forums.phpfreaks.com/topic/218703-daterange-to-post/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.