Re: Infinite Loop Issue

From: Date: Thu, 06 Nov 2008 21:38:15 +0000
Subject: Re: Infinite Loop Issue
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-283029@lists.php.net to get a copy of this message
Kyle Terry wrote:
I believe I'm doing everything right here. It just seems like it doesn't end. The browser just keeps trying to load the page forever... function displayAll(){
    global $db;
    $sql = "SELECT release_id, description, date(release_date) date, issues,
priority FROM release_data";
    $all = $db->prepare($sql);
    $all->execute();
    $all->bind_result($release_id, $description, $date, $issues, $priority);
    while($all->fetch()){
        $i = 0;
        $iss_link = explode(', ', $issues);
        foreach($iss_link as $a){
          $row2[$i] = "<a href=\"http://mantisus/view.php?id=$a\"
target=\"_blank\">".$a.'</a>';
          $i++;
        }
In pseudo code you have: for each result from the db explode the issues add another issue to the list So: no issues at start row 1 fetched explodes issues adds another issue (1 issue) row 2 fetched explodes issues (now 1) add another issue (now 2) row 3 fetch explode issues (now 2) add another issue (now 3) and so on. So your list is getting longer and longer and you're adding to it for each row you get from the db. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#283029) next »