List upcoming events only

24 posts by 7 authors in: Forums > CMS Builder
Last Post: February 24, 2015   (RSS)

By claire - February 16, 2015

I'm afraid I can't provide an accurate where clause unless I know more about how your sections are structured, sorry.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By proba - February 16, 2015

For now it is:

<?php
  require_once "........./lib/viewer_functions.php";

  list($afishRecords, $afishMetaData) = getRecords(array(
    'tableName'   => 'afish',
    'where' => 'date <= ((NOW() + INTERVAL 7 DAY) AND date >= NOW()',
  ));

?>

with foreach:

<?php foreach ($afishRecords as $record): ?><section>
            <header>
                <h1 style="width:90%;"><span style="font-size:12px;"><?php echo date("d.m.Y", strtotime($record['date'])) ?></span><br /><?php echo $record['title'] ?></h1>
            </header>
            <div class="content" style="width:100%;">
            <?php echo $record['content'] ?>
            </div>
        </section><?php endforeach ?>

and got this error - "MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY dragSortOrder' at line 4"

By claire - February 17, 2015

Okay, change your query to this:

<?php
  require_once "........./lib/viewer_functions.php";

  list($afishRecords, $afishMetaData) = getRecords(array(
    'tableName'   => 'afish',
    'addSelectExpr' => 'date <= ((NOW() + INTERVAL 7 DAY) AND date >= NOW()',
  ));

?>

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By proba - February 17, 2015

Ok now i got this error - "MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `cms_afish` as `afish` ORDER BY dragSortOrder, date ASC' at line 2"

By claire - February 17, 2015

Can I confirm what the name of your date variable is, please?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By proba - February 19, 2015

Yes the name of the variable is - "date"

By claire - February 19, 2015

Okay, you can try a different version of this:

<?php
  require_once "........./lib/viewer_functions.php";

  list($afishRecords, $afishMetaData) = getRecords(array(
    'tableName'   => 'afish',
    'where' => 'date <= "'.date('Y-m-d H:i:s', time()+(60x60x24x7)).'" AND date >= "'.date('Y-m-d H:i:s', time()).'"',
  ));

?>

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By proba - February 24, 2015

this code have syntax error in "where"

<?php
  require_once "........./lib/viewer_functions.php";

  list($afishRecords, $afishMetaData) = getRecords(array(
    'tableName'   => 'afish',
    'where' => 'date <= "'.date('Y-m-d H:i:s', time()+(60x60x24x7)).'" AND date >= "'.date('Y-m-d H:i:s', time()).'"',
  ));

?>

By claire - February 24, 2015

What's the syntax error, please?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/