how does this php code where does the table db read happen

Posted on 2013-11-23
Last Modified: 2013-11-24
have the below code debugging and monitoring the $item variable then when it gets to
foreach ($this->items as $item) { the data is magically there but the de bug does not step off to the db read can some one please explain how this works

function initdata(){
//      $bbc = $user['id'];

      $curcatnum = -1;
      $itemnum = -1;
      $curcat = '';

      foreach ($this->items as $item) {
          if ($curcat != $item->category) {
                  $itemnum = 0;
                     $curcat = $item->category;
                     echo ('price_list['.$curcatnum.'] = new Array();'."\n");
            echo ("      price_list[".$curcatnum."][".$itemnum."] = ".$item->cost."; ");
Question by:sydneyguy
  • 3
  • 2
  • 2
  • +1
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 300 total points
ID: 39671355
Without seeing the actual code, it may be impossible to help, but I'll make a guess.  Since initdata() is a PHP function, it has its own variable scope.  Variable names inside the function are isolated from names outside the function.
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 100 total points
ID: 39671388
Are you using some framework?
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 300 total points
ID: 39671393
@marqusG: Based on the Zones, probably Joomla.
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 100 total points
ID: 39671418
Lol, didn't see: it's written too little... :)
LVL 43

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 100 total points
ID: 39671432
You've only shown part of the code so it's impossible to see. Something is happening before your code gets here to set the scope of $this

@Ray - it looks like the initdata() is a Javascript function - it's just using PHP to populate a Javascript array
LVL 109

Accepted Solution

Ray Paseur earned 300 total points
ID: 39671462
initdata() is a Javascript function
Good probability.  So much is missing from the question that it's hard to discern what the real issue might be!

Author Comment

ID: 39671819
sorry about that forgot yes its joomla 3 and yes there is some code missing this is the code that i am trying to figure out this would be the actual setup of the extraction of the db, this is the code that i cannot find, its not that i am holding any thing back intentionally i just cannot find the code were it sets up this array of data records, this is what i am trying to find,
 will step through the code now and see what i can come up with  
the module is com_ipricecalc if you have used that before

Author Closing Comment

ID: 39672528
thanks for the help

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
insert into database through form with dynamic fields. 2 31
Dynamic varibles 5 33
Decrypt string by php 7 31
What does this formatting equate to? 7 10
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question