0

Hello I have the following php script

$db =& JFactory::getDBO();
$sql = "select uid from #__zcalendar_events where article_id = " . $article->id;
$db->setQuery($sql);
$results = $db->loadObjectList();
    if(count($results)) {
        foreach($results as $r => $value) {
            $sql = "select catid from #__zcalendar_event_categories where uid = " . $r->field1;
        print_r($results);
        print_r($sql);

My problem start in this line:

$sql = "select catid from #__zcalendar_event_categories where uid = " . $r->field1;

the . $r->field1; does not add the value to the string $sql.

But if I print_r($results); I get the this information:

Array ( [0] => stdClass Object ( [uid] => [email protected] ) )

And I need just this: [email protected]

and . $r->field1; have to had this information but it's always empty.

Can someone please help me to solve this problem, because I have the information. But never works.

2
  • Are you meaning to use $value->field1, not $r perhaps? Commented Sep 19, 2011 at 13:51
  • Also, you have 7 questions and you've not accepted any of them. You might want to work on that. Commented Sep 19, 2011 at 13:58

1 Answer 1

1

A foreach is usually like this:

foreach($array as $key => $element)

Are you sure you want to be using the $r not the $value?

Sign up to request clarification or add additional context in comments.

6 Comments

+1 - and the other mistake was to use $value->field1 but there is no field1 instead he should write $value->uid
Yes I want the uid, but I don't know how to get it.
So does $value->uid give you [email protected]?
You're very welcome. Please mark an answer as correct or up if it helped you out.
Hey I have another proble, the value that I get goes to this link $link = "option=com_zcalendar&vmode=e&view=".$eventview."event&format=html&tmode=m&eid=$eid"; in the .$eventview. but I get this empty but it have the value. Can you help me with this, too???
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.