Jump to content

Using date variable from form in WHERE statement


im8kers

Recommended Posts

Hello,

 

I have been searching everywhere to figure this out but haven't found anything.  So either it's stupid simple or I'm going about it the wrong way.  Here is my sql code:

 

SELECT p.*, c.bagsrecd, c.recddate, c.locationid

FROM ninlf_received AS c INNER JOIN ninlf_recipient AS p

ON c.recipientid = p.recipientid

WHERE c.recddate >= '$_POST["start"]' AND c.recddate <= '$_POST["end"]'

 

I need to filter the data by the variables from a previous page post.  I am using MySQL 5.0 and will create this as a view.

 

Thanks.

then try something like this

 

$query="SELECT p.*, c.bagsrecd, c.recddate, c.locationid

FROM ninlf_received AS c INNER JOIN ninlf_recipient AS p

ON c.recipientid = p.recipientid

WHERE c.recddate >= ".$_POST['start']."AND c.recddate <= ".$_POST['end'];

 

before running the query first echo ur query like

echo $query;

and then execute if ur varibles are interpreted.

 

 

 

Here is the code again.  Again I'm attempting to have this code run from the mysql database and not from the php page.

 

 

SELECT p.*, c.bagsrecd, c.recddate, c.locationid
FROM ninlf_received AS c INNER JOIN ninlf_recipient AS p
ON c.recipientid = p.recipientid
WHERE c.recddate >= '$_POST["start"]' AND c.recddate <= '$_POST["end"]'

I guess that is my question.  It all works from the page source in the php query, but that's not where I need it.

 

Do you have any recommendations how I can make the mysql source "look or refer" to the $POST variable?

I don't really know what this means.

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.