How do I code a loop for my echo statement?

Posted by ggg on Stack Overflow See other posts from Stack Overflow or by ggg
Published on 2010-03-26T14:39:53Z Indexed on 2010/03/27 2:33 UTC
Read the original article Hit count: 342

Filed under:
|
|
|
|

I get only one printed result in the foreach echo loop at the bottom of the page.

<?php
    defined('_JEXEC') or die('Restricted access');
    $db =& JFactory::getDBO();

    $query0 = "SELECT * FROM  `jos_ginfo` WHERE . . . LIMIT 30";

    //echo $query0;
    $db->setQuery($query0);
    $ginfo = $db->loadObjectList();
    //echo
    //$ginfo[0];
    foreach($ginfo as $ginfo[$i]):
    {$i=0; $i++;} 
     endforeach;
    echo $db->getErrorMsg();

    if(empty($ginfo)){
    echo "<center>No
    game found, try a different entry.</center>";
    }else{


    $pgndata = array ( $ginfo[$i]->Id);

        $i=0;
    foreach($pgndata as $ginfo[$i]->Id):
    //I am only getting one printed result!
    {
        echo "<a href='/index.php?option=com_publishpgn&tactical-game=".$ginfo[$i]->Id."&Itemid=78.html'>\n";
    echo "".$ginfo[$i]->White." v. ".$ginfo[$i]->Black."  (".$ginfo[$i]->Result.") ".$ginfo[$i]->EventDate." ECO:".$ginfo[$i]->ECO."</a><br>\n";

    $i++;
    }

     endforeach;

    //echo "</div>";
        }
    ?>

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php