Improve company productivity with a Business Account.Sign Up

x
?
Solved

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

Posted on 2013-11-23
8
Medium Priority
?
320 Views
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(){
<?php
//      $bbc = $user['id'];

      $curcatnum = -1;
      $itemnum = -1;
      $curcat = '';
      // THIS IS THE READ POINT

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

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1200 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.
0
 
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 400 total points
ID: 39671388
Are you using some framework?
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1200 total points
ID: 39671393
@marqusG: Based on the Zones, probably Joomla.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 31

Assisted Solution

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

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 400 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
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1200 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!
0
 

Author Comment

by:sydneyguy
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
0
 

Author Closing Comment

by:sydneyguy
ID: 39672528
thanks for the help
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

579 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