How do I code a loop for my echo statements?

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/26 14:43 UTC
Read the original article Hit count: 224

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


$query0 = "SELECT * FROM `#__chesspositions` WHERE . . . . .";

//echo $query0;
$db->setQuery($query0);

$ginfo = $db->loadObjectList();
//echo
$ginfo[0];
echo $db->getErrorMsg();

if(empty($ginfo)){
echo "<center><h2 style='color:navy'>No
game found, we apologize</h2></center>";
}else{

$query1= "SELECT * FROM `#__chessmoves` WHERE Id='".$ginfo[0]->MoveDataId."'";

$db->setQuery($query1);
echo $db->getErrorMsg();

$gmove = $db->loadObjectList();

}


//define array;

//how do I code a foreach loop (or any other type of loop) here?
//I'm having trouble properly defining the array and structuring the syntax. 

echo "[Event \"".$ginfo[0]->Event."\"]\n";

echo "[Site \"".$ginfo[0]->Site."\"]\n";

echo "[Date \"".$ginfo[0]->Date."\"]\n";

echo "[Round \"".$ginfo[0]->Round."\"]\n";

echo "[White \"".$ginfo[0]->White."\"]\n";

echo "[Black \"".$ginfo[0]->Black."\"]\n";

echo "[Result \"".$ginfo[0]->Result."\"]\n";

echo "[ECO \"".$ginfo[0]->ECO."\"]\n";

echo "[WhiteElo \"".$ginfo[0]->WhiteElo."\"]\n";

echo "[BlackElo \"".$ginfo[0]->BlackElo."\"]\n";

echo "[Annotator \"".$ginfo[0]->Annotator."\"]\n";

echo "[SetUp \"".$ginfo[0]->SetUp."\"]\n";

echo $gmove[0]->MoveData;

?>

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php