Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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!!!!!!!!


$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">

    <td width="83" height="27">Time Series:</td>
    <td width="105">
      <select name="TS" id="TS">
while( $row = mysql_fetch_array($result) )
    echo '<option value="'.$row['NewD'].'">'.$row['NewD'].'</option>';
      </select></td>   </tr> </table>

Re: php

Quoted text here. Click to load it

07/10/2006 is NOT the date format that MySQL uses.  MySQL wants
2006-07-10 or 2006-10-07, depending on what country's date format
07/10/2006 is intended to be.

If you wish to convert TO MySQL's date format, try str_to_date().
If you wish to convert FROM MySQL's date format to some other format,
try date_format().

Re: php

kirke wrote:
Quoted text here. Click to load it

Gordon has told you one problem, but there are others.

Even if you were right about the date format,


would deliver the first bit of the date - in your format, the month  
only. (see ).

You can't just expect a date to convert to a usable integer like that.

Secondly, you've already pointed out the weakness of using LEFT for what  
you want to do. Use one of the DATE functions: see

Thirdly, your question about forms: no, you can give only one URL far  
'action'. If you want to be able to go to different pages (presumably  
depending on values in the form) you need to write a CGI script that  
takes the values from the form, decides which page to go to, and then  
issues  an appropriate

You must make sure you do not output anything (not even spaces) before  
the header.


Site Timeline