This topic is locked
[SOLVED]

 SELECT * Where date = today

12/27/2012 1:18:33 PM
PHPRunner General questions
J
jackheitzer@gmail.com author

Hi,
I've only been working with phprunner 6.2 for a week now so I hardly have any experience.
I have a table containing events, 1 or 2 events each day. One of the fields is "Date" (datum). I would like to create a listpage with a query which selects the events for today. I handcoded an earlier project and the following code worked:
$today=date("Y-m-d");

$result = mysql_query("SELECT
FROM voorstelling WHERE datum='$today'");*
I can't seem to find where to put it in phprunner 6.2.
Does anyone have any tips for me?
Thanks,
Jack

C
cgphp 12/27/2012

You don't need that code.

In the "Before SQL query" event (http://xlinesoft.com/phprunner/docs/before_sql_query.htm) of the voorstelling table, enter the following code:

$strWhereClause = whereAdd($strWhereClause,'datum = '.date("Y-m-d"));
Sergey Kornilov admin 12/27/2012

You can avoid using PHP code if you need select todays data only. Here is the sample SQL query:

SELECT ... FROM ... WHERE date_field > DATE_SUB(NOW(), INTERVAL 1 DAY)


Replace 'date_field' with the actual date field name.

J
jackheitzer@gmail.com author 12/27/2012



You can avoid using PHP code if you need select todays data only. Here is the sample SQL query:

SELECT ... FROM ... WHERE date_field > DATE_SUB(NOW(), INTERVAL 1 DAY)


Replace 'date_field' with the actual date field name.


Thanks Sergey for your reply. I'm affraid it didn't work exactly as supposed. It didn't only return today's data but also all following days. Any more thoughts?
Thanks,
Jack.

J
jackheitzer@gmail.com author 12/27/2012



You don't need that code.

In the "Before SQL query" event (http://xlinesoft.com/phprunner/docs/before_sql_query.htm) of the voorstelling table, enter the following code:

$strWhereClause = whereAdd($strWhereClause,'datum = '.date("Y-m-d"));



Hi Cristian,
Thanks for your reply, however your soluyion didn't return any results. Do you have any idea why not?
Thanks,
Jack

C
cgphp 12/28/2012

The correct code is the following:

$strWhereClause = whereAdd($strWhereClause,"datum = '".date("Y-m-d")."'");
J
jackheitzer@gmail.com author 12/28/2012



The correct code is the following:

$strWhereClause = whereAdd($strWhereClause,"datum = '".date("Y-m-d")."'");



Thanks, this did the trick!