Had to use multiple queries
function content_series_links($page_id) {
/ First all the error checking /
$this->verify_integers($page_id);
$qry="SELECT prev, title FROM ";
$qry.="$this->master_table WHERE ";
$qry.="page_id = '$page_id'";
$result=mysql_query($qry);
$row=mysql_fetch_array($result);
if(!$row["prev"] || $row["prev"] != NULL) {
return FALSE;
}
// set the first element based on the input id.
$links[$page_id]=$row["title"];
$continue=TRUE; // Flag signifies data is to be added to links array
while($continue) {
$qry="SELECT prev, page_id, title FROM ";
$qry.="$this->master_table WHERE ";
$qry.="prev = '$page_id'";
$result=mysql_query($qry);
$row=mysql_fetch_array($result);
if ($row["prev"] != $page_id) { //if its not linked thats the end of the loop
$continue=FALSE;
} else {
$links[$row["page_id"]]=$row["title"]; //add link to array
$page_id=$row["page_id"];
$continue=TRUE;
}
}
return $links;