This topic is locked
[SOLVED]

 Display related data in grid on List Page

2/9/2011 9:42:28 AM
PHPRunner General questions
F
fmbma author

I've looked at examples for using a custom field in the grid on a list page. I'm using the following code to display links to related data in a custom field:



global $dal;

$value = "Journeys

";
$tblJourney = $dal->Table("tblJourney");

$rs = $tblJourney->Query("WorldID=".$data["WorldID"],"");
$rdata = db_fetch_array($rs);

while($rdata=db_fetch_array($rs))

{

$value = $value.("<a href=some_page.php?journey=".$rdata["JourneyID"].

">".$rdata["JourneyName"]."</a>

");

}


It sort of works. On the first row of the grid, it correctly displays links to 2 out of three records that should be returned. However, on the rest of the rows of the grid, it does not display any of the links that should be returned. Can anyone see something obvious in the code? Should I not use the DAL?

F
fmbma author 2/9/2011

I figured it out - The line $rdata = db_fetch_array($rs); was doing an initial unnecessary row read before reading again in the loop on the line below it.



I've looked at examples for using a custom field in the grid on a list page. I'm using the following code to display links to related data in a custom field:



global $dal;

$value = "Journeys

";
$tblJourney = $dal->Table("tblJourney");

$rs = $tblJourney->Query("WorldID=".$data["WorldID"],"");
$rdata = db_fetch_array($rs);

while($rdata=db_fetch_array($rs))

{

$value = $value.("<a href=some_page.php?journey=".$rdata["JourneyID"].

">".$rdata["JourneyName"]."</a>

");

}


It sort of works. On the first row of the grid, it correctly displays links to 2 out of three records that should be returned. However, on the rest of the rows of the grid, it does not display any of the links that should be returned. Can anyone see something obvious in the code? Should I not use the DAL?