PHP Classes

help needed on php object design

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  help needed on php object design  
Subject:help needed on php object design
Summary:need to use the result of one function as input for another
Messages:2
Author:Hobke
Date:2012-04-11 09:56:41
Update:2012-04-11 21:11:53
 

  1. help needed on php object design   Reply   Report abuse  
Picture of Hobke Hobke - 2012-04-11 10:33:03
Hello All,

Hope someone can help me with this one ...

I would like to us the result of one function as parameter to another funtion.

This is the class info:

class portalContent
{
var $portalQuickLinks;
var $portalQuickCategories;

public function getPortalQuickCategories ($siteLang)
{
// does stuff here
$this->portalQuickCategories = mysql_query("SELECT ...");
return $this->portalQuickCategories !== false;
}

public function getPortalQuickLinks ($siteLang, $quickCategory)
{
//does stuff here
$this->portalQuickLinks = mysql_query("SELECT ...");
return $this->portalQuickLinks !== false;
}

public function displayPortalQuickLinks ($siteLang)
{
echo "step1 - "; //debugging
if($this->getPortalQuickCategories($siteLang)==true)
{
echo "step2 - "; //debugging
while ($row_c = mysql_fetch_object($this->portalQuickCategories))
{
echo "step3 - "; //debugging
$this->getPortalQuickLinks($siteLang, $row_c->QUICK_TITLE);
echo "<div id=\"footerMS\">";
echo "<h2>"; print_r ($row_c->QUICK_TITLE); echo "</h2><ul>";
if ($this->getPortalQuickLinks($siteLang, $row_c->QUICK_TITLE)==true)
{
while ($row_l = mysql_fetch_object($this->portalQuickLinks))
{
echo "step4 - "; //debugging
echo "<li><a href=\"##\"> "; print_r($row_l->QUICK_ITEM); echo "</a></li>";
}
echo "</ul></div>";
}
else
{
echo "oops no elements found";
}
}
}
else
{
echo "oops no footer found";
}
}

}

Then in the php page I include the class and us it as follows:

<?php
$myQuickFooter = new portalContent();
$myQuickFooter->displayPortalQuickLinks($siteLang);
?>

Output is now "step1 - step2 - "

Not sure how I can get the result from the first function (a set of categories) to be inserted as parameter to the second function to get the set of links according to the category.

The queries do give me the results needed. That has been tested via phpMyAdmin console.

Must be something wrong in my class definition ?


Regards,
Hob.

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.