tags:

views:

61

answers:

1

Very quick question, I think the tiredness is getting to me;

How would I limit this query so it only gives me one result?

Code:

function next_prodn_header() {

    $StartDate = get('start_date');
    $timestamp = strtotime($StartDate);

    $EndDate = get('end_date');
    $Now = strtotime(date('d-m-Y'));
    $Start = strtotime($EndDate); 
    $newStart = date_i18n('d-m-Y', $Start);

    if ($Now <= $Start) {

 for ($i = 1; $i < 1; $i++) {
     echo "<h2>Next Event</h2>";
     echo "<span class=\"month\">";
     echo date_i18n('M', $timestamp);
     echo "</span>\n";
     echo "<span class=\"year\">";
     echo date_i18n('Y', $timestamp);
     echo "</span>\n\t\t";
     echo "<p><a href='";
     echo the_permalink();
     echo "' title='";
     echo the_title();
     echo "'>";
     echo the_title();
     echo "</a></p>\n\t\t";
     }
    } else {
  echo "";
    }
}
+2  A: 

If by query you meant your for loop, start the loop at $i = 0. As of right now, your for-loop structure checks if 1 < 1 which evaluates to false, so it doesn't run the code inside of the loop.

Otherwise, I am not exactly sure what your question is regarding.

Anthony Forloney