Page 1 of 1

cant get the value from the textbox

Posted: Wed May 09, 2007 9:13 pm
by pleigh
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi, i have this code

Code: Select all

if ($_REQUEST["startdate"]) {
$startdate = $_REQUEST["startdate"];
} else {
$startdate = "2006-06-01";
}
								
$enddate = $_POST["enddate"];
								
if ($startdate) {
$sqlstart = "AND date(l.date) >= '" . $startdate . "' ";
}
								
if ($enddate) {
$sqlend = "AND date(l.date) <= '" . $enddate . "' ";
}
and inside the <td></td>

Code: Select all

if ($startdate) {
echo "Start Date<br><input id=\"startdate\" name=\"startdate\" type=\"text\" size=\"25\"><a href=\"javascript:NewCal('startdate','ddmmyyyy')\">
<img src=\"javascript/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
}

if ($enddate) {
echo "End Date<br><input id=\"enddate\" name=\"enddate\" type=\"text\" size=\"25\"><a href=\"javascript:NewCal('enddate','ddmmyyyy')\">
<img src=\"javascript/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
}
first problem is that when i run this code, there is only one textbox that appears, the startdate textbox, when i tried to edit the second textbox, replaced the $enddate with $startdate, it will appear. next problem is that there are no values passed frm the textbox to the $_REQUEST["startdate"] and $_REQUEST["enddate"], the effect is that i cannot filter the query with the specified date.

hope you can help me. thanks very much.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed May 09, 2007 11:27 pm
by volka
please try

Code: Select all

echo '<pre>_REQUEST: ', var_export($_REQUEST); echo '</pre>';
echo '<pre>_GET: ', var_export($_GET); echo '</pre>';
echo '<pre>_POST: ', var_export($_POST); echo '</pre>';

if ($_REQUEST["startdate"]) {
  $startdate = $_REQUEST["startdate"];
} else {
  $startdate = "2006-06-01";
}

$enddate = $_POST["enddate"];

echo '<pre>startdate: ', var_export($startdate); echo '</pre>';
echo '<pre>enddate: ', var_export($enddate); echo '</pre>';

if ($startdate) {
  $sqlstart = "AND date(l.date) >= '" . $startdate . "' ";
}
                        
if ($enddate) {
  $sqlend = "AND date(l.date) <= '" . $enddate . "' ";
}
and post the output.

Posted: Wed May 09, 2007 11:56 pm
by pleigh
hi, thanks for the reply, i did that code and the output is
_REQUEST: array (
'tab' => 'td',
'rpt' => '16',
'sort' => 'daily',
'sortmonth' => '',
'sortweek' => '200618',
'startdate' => '',
'enddate' => '',
'PHPSESSID' => '7e91d165cab6df3a9e742593592cefad',
)

_GET: array (
'tab' => 'td',
'rpt' => '16',
'sort' => 'daily',
'sortmonth' => '',
'sortweek' => '200618',
'startdate' => '',
'enddate' => '',
)

_POST: array (
)

startdate: NULL

enddate: NULL

Posted: Wed May 09, 2007 11:59 pm
by pleigh
maybe this one will help, i think there is a problem when it comes to the format of the date, because in my javascript, the format is ddmmyyyy, and then the format in php is YYYY-MM-DD...i am just guessing, and if that is the problem, how will i be able to convert the javascript format to YYYY-MM-DD?

:)

Posted: Thu May 10, 2007 1:06 am
by volka
Your form's method is GET. Therefore
pleigh wrote:$enddate = $_POST["enddate"];
doesn't work. Either change the form's method to POST or use $_GET["enddate"].

You must have changed your script to get
pleigh wrote:startdate: NULL
.