Jump to content
funbinod

if 'submit' do something is not working

Recommended Posts

i'm trying to get make query relating to the date selection. and if no date is selected, i want to make default query without date selection.

for this i tried this ----

// above this there is a form with two input fields for from date and to date selection with a submit buttom. action is $_SERVER['PHP_SELF']if (!isset($_POST['sort'])) {     // 'sort' is the submit button name$query = "SELECT * FROM tran WHERE ssn!=0 ORDER BY date";} else {	$fdate == $_POST['fdate']; // from date	$tdate == $_POST['tdate']; // to date$query = "SELECT * FROM tran WHERE ssn!=0 AND date BETWEEN '$fdate' AND '$tdate' ORDER BY date";}

but this is not working...

 

any suggestion!!!?????

Share this post


Link to post
Share on other sites

You tried to use == to assign a value, that doesn't work. == is for comparison.

 

this means single = (or something else) would work?

Share this post


Link to post
Share on other sites

single = is also not working.

if (!isset($_POST['sort'])) {$query = "SELECT * FROM tran WHERE ssn!=0 ORDER BY date";} else {$fdate = $_REQUEST['fdate'];$tdate = $_REQUEST['tdate'];$query = "SELECT * FROM tran WHERE ssn!=0 AND date BETWEEN '$fdate' AND '$tdate' ORDER BY date";}

it returns the query on if statement. but even after selecting the date it is the query from if statement (or simply the if, else statement is not working)..

Share this post


Link to post
Share on other sites

Check what does $_POST['sort'] returns. Use var_dump()

Share this post


Link to post
Share on other sites

Believe me, if statements in PHP work just fine. It is doing exactly what you are telling it to do. The value that you are checking in the if statement is true.

Share this post


Link to post
Share on other sites

there is no reason not to believe u. i'm nothing in comparison to a php tycoon like u. i was just asking for other possible reasons for it.

 

and now i found it. shame on me. i just forgot to place method="post" into the form.

 

thank u for ur company.

Edited by funbinod

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...