Jump to content

NotSureILikePHP

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by NotSureILikePHP

  1. That didn't work. It's being called from a different page so I'll include all the code. customers.inc.php $locations = Cust::getLocations($customerID); echo 'locations = '.$locations[0]['location_id']; [/] class.customer.php [code] function getLocations($custID) { $locs = array(); $sql='SELECT DISTINCT l.location_id, l.site_name FROM ' //l.location_id, l.site_name, CONCAT(l.fname, " ", l.lname) AS contactName, email, ' //.'l.phone_number, l.fax_number, c.cust_id, l.address1, l.address2, l.city, ' //.'l.state, l.zip_code, l.contact_number FROM ' .CUST_TABLE.' c ' .' LEFT JOIN '.CUST_LOCATION_TABLE.' l ON (l.cust_id=c.cust_id) ' //.' INNER JOIN '.DEPT_TABLE.' d ON (LOCATE(CONCAT("/", s.dept_id, "/"), d.path) OR d.manager_id=s.staff_id OR LOCATE(CONCAT("/", g.dept_id, "/"), d.path)) ' .' WHERE c.cust_id='.$custID; //.db_input($this->getId()); if (($res=db_query($sql)) && db_num_rows($res)) { while(list($loc)=db_fetch_row($res)) { $columns = array ( 'locID' => $loc['location_id'], 'locName' => $loc['site_name'], ); $locs[] = $columns; } } return $locs; } [/] result is locations = I commented out a lot of that select just to limit it to two columns for now.
  2. It is an empty array I'll try that
  3. I'm trying to add multiple columns to an array. To simplify I'll just say id and name for now. How do I add and call that in the code. I am an asp developer, though it's been a while, so in asp it's something like array[0],["columnName'] Though in php that dot means to concat. Here's my code. $int = 0; if (($res=db_query('SELECT id, name FROM location')) && db_num_rows($res)) { while(list($loc)=db_fetch_row($res)) { $columns = array ( 'locID' => $loc['location_id'], 'locName' => $loc['site_name'], ); array_push($locs[$int], $columns); $int++; } } [/] I'm not sure if that's working or not because I don't know how to get values from the index of the array in php. Most of the code I google seems like an array can only store one value per index.
  4. I do have Eclipse installed but I can't figure out how to chase the rabbit. I can get it to debug on certain pages but I have spent 30 minutes hitting step into and not gotten to the spot that I want because the code is so convoluted. It starts debugging right away and I have told it not to in the settings and when I hit play the first time it never hits another breakpoint. Is there a better debugger than Eclipse and XDebug or am I just doing something wrong?
  5. I NEVER get a good answer here so I stopped posting and just post on PHP Phreaks but this is way too confusing so I have to try here. I can NOT for the life of me figure out what is going on with this code. It's so horribly coded and I'm new to php so it's like trying to learn Mandarin from a special needs kid. I created a class called Customers by mimicking the staff class. I can populate my grid with all the customers but when I try to search by a specific customer I have to know the full name WITH all the right capitalization. I'm trying to track down where the query is called but these coders don't use stored procedures they dynamically build them and it's one of the most complicated things I've ever seen. Here's the line of code I'm trying to trace, I think.... if ($filters) { $custs->filter($filters); } [/] Now I can find this function and when I echo what it returns it returns the querystring WHERE A1.`cust_name` = 'test' which is exactly what I am looking for. However, I can't trace it any further than that. This is the code in that function [code] foreach (func_get_args() as $Q) { $this->constraints[] = $Q instanceof Q ? $Q : new Q($Q); } [/] The Query looks like SELECT A1.`cust_name` FROM `ost_customer` A1 WHERE A1.`cust_name` = 'test' I have spent HOURS searching this code for A1 (returns thousands of rows), SELECT (which returns even more rows around 4 thousand), CUST_TABLE which is the variable my customer table name is stored and I have found NOTHING. Can anyone help me find where this code is located so I can change it? I really wish they just used stored procedures. It would make this whole project so much more readable. I would also like to know how to add % to a textbox. For example, I have a textbox so that the user can type "Test" and it should return 1 customer in the database named "Testy Corporate" but it doesn't unless you type the whole name. I would like to add % to the beginning and end like "%test%". However, when you hit submit it posts back and runs the query. Now, I'm assuming if I ever find the place where the sql statement is called I should be able to change that but is there a way that when you hit submit it automatically appends that to the text?
  6. I'm assuming this is a function in php, though still not entirely sure what arrows are in coding. Here's the line: if ($filters) $custs->filter($filters); [/] $Custs is an object of type customer. Other languages don't have -> but if I'm not mistaken it's a function. I'm searching the entire project for "function filter" and I get 3 results but none of them are the right location. Only one of them accepts parameters and I know it's not the right code because it never reaches that function. Can someone tell me exactly what I should be looking for? I'm trying to search for a specific customer. However it's searching on customer name = "whatever" rather than customer name like "whatever" and I can't seem to find where it's defined in the code.
  7. Thanks, I for some reason was thinking because I didn't need to display it I didn't need to echo it.
  8. I might have figured this out by the time I get a response but then again maybe not. I am trying to dynamically add hyperlinks to a grid that I am populating. Here is the code: <?php if ($count) { $ids= ($errors && is_array($_POST['ids'])) ? $_POST['ids'] : null; foreach ($custs as $cust) { $id = $cust->getId(); $name = $cust->getName(); ?> <tr id="<?php echo $id; ?>"> <td width=7px> <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $id; ?>" <?php echo $sel? 'checked="checked"' : ''; ?> <?php echo $default? 'disabled="disabled"' : ''; ?> > </td> <td><a href="customers.php?t=customer&id=<?php $id ?>"><?php echo $name; ?></a></td> </tr> <?php } //end of foreach. } ?> [/] It builds the link customers.php?t=customer&id= However, when I echo out the $id it displays. I'm sure there's something simple I'm not doing here but not sure what it is.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.