|
Posted by kirke on 10/08/06 03:10
Help me guys. I have several problems in following code :
SQL query code doesn't work. I connect to My SQL Server. and
'StartDate' is the name of textbox. it forms 07/10/2006
Thus, I receive two dates as $StartD and $EndD.
Original dtDateTime looks like 07/10/2006 11:23:44
I want to select only between $StartD and $EndD. However
=> WHERE dtDateTime Between ' $StartD ' AND ' $EndD '
doesn't work.
Second problem is
=> DISTINCT(LEFT(dtDateTime,9)) As NewD
'dtDateTime' has time data, but i wanna only date. Thus, i select
LEFT(~,9) (it also have problem when month and date both have two
numbers (11/22/2006) but i have no idea except LEFT commend)
Also I want to use DISTINCT. and put the list of distinct dates in
drop-down box.
So i use
=> echo '<option value="'.$row['NewD'].'">'.$row['NewD'].'</option>';
Also this part doesn't work.
Another question is,
in form, can I assign multiple pages as action page?
Or there's other way to use values in non-action page?
Following is whole code.
Thank you!!!!!!!!
$StartD=(int)$_POST['StartDate'];
$EndD=(int)$_POST['EndDate'];
<?php
$sql = "SELECT DISTINCT(LEFT(dtDateTime,9)) As NewD FROM dbo_J1708Data
WHERE (dtDateTime Between ' $StartD ' AND ' $EndD ' )";
$result= mysql_query($sql) or die();
?>
<form id="form1" name="form1" method="post" action="result.php">
<table>
<tr>
<td width="83" height="27">Time Series:</td>
<td width="105">
<select name="TS" id="TS">
<?php
while( $row = mysql_fetch_array($result) )
{
echo '<option value="'.$row['NewD'].'">'.$row['NewD'].'</option>';
}
?>
</select></td> </tr> </table>
[Back to original message]
|