Newbie questions. Please help. I am lost!!!!! Retriving information via REST API

This will seem so ridiculous, but I am such a newbie to PHP and anything other than HTML so I am LOST as to how to get my project working (on which my job depends right now).

We use sugar to manage our customers. I created an HTML front end in Joomla to view similar to the design of SUGAR CRM so that when the client logs in, they can view their sugar account information. I have been provided a series of REST calls for the API to retrieve information, and I have figured out how to call to objects (for instance using the variable<span class="sugar_field" id="name"><?=$rest->account->name ?></span>) to get the user account name. I however am now trying to pull all the contacts associated with an account, which I was able to do by creating a FOREACH loop.

I want to create a “detail view” of the contact once it is clicked on (so I am assuming I would link the name of the contact to the “detail view” so that when the name is clicked on, it gives you the details of the contact, which can then have option to edit the contact from that screen. since there is no set number of contacts that can be associated with any given account, how do I reference the data from Contact1, contact2, contact3 ect to be displayed on any given “Detail view” page? I am assuming I cant use the variable <?=$rest->contacts[0]->first_name ?> because this assigns a specific ID and I am not sure which ID will need to be detailed out as the user might click on the detail view for ID 1. does this make sense?

I was told the solution is this:

You could add a counter to the foreach loop:

$i = 0;
foreach($rest->contacts as $contact)
// your link will have a dynamic href, so something like$i

When you go to the detail view you can just use $rest->contacts[$_GET['id']]->first_name

But I HAVE NO IDEA how to implement this into my code. Can someone help me?

I also have no idea how to allow the information to POST back to sugar once the form field is edited.

I apologize for the beginner questions… but I would be so appreciative if someone might be able to hold my hand through this a little bit. Im a quick learner but I have no idea where to start!!!

Thanks in advance!

I have zero clue what you need to do. You should start by doing var_dump($rest) to see what data you have to work with.

Sponsor our Newsletter | Privacy Policy | Terms of Service