I have a strange problem,
I am calling 'findTheParent' function from 'nextPrimaryTopic' function,
The function findTheParent should return a value to 'nextPrimaryTopic' function,
But it is not happening so, While echo " findTheParent($topicId)" in 'nextPrimaryTopic' function, it echos but it does not assign the value to the variable. Could you please help me crack this?
Code: Select all
function nextPrimaryTopic($topicId){
if(isItaParent($topicId)){
$currentTopicId = $topicId;
}
else{
$currentTopicId = findTheParent($topicId);
echo "returned:",findTheParent($topicId);
}
}
function findTheParent($topicId){
// to find the parent of a given topic which is already proven as a child
$sql = "select id, parent_id from topics where id=".$topicId;
$conn = getConnection();
$db = getDb();
$result = mysql_query($sql, $conn) or die ("Sorry, Could not execute the query. ".mysql_error());
$parentRec = mysql_fetch_array($result);
if($parentRec['parent_id'] == 0){
echo $parentRec['id'];
return $parentRec['id'];
}
findTheParent($parentRec['parent_id']);
}