开发者

Limit a php function to one result [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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开发者_StackOverflow社区-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 "";
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜