Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About smartalco

  • Rank

Contact Methods

  • AIM
  1. I'm trying to simplify my SQL statement just for readability sake. Here's what I have for the FROM part. FROM departments as d INNER JOIN people as p1 INNER JOIN people as p2 INNER JOIN people as p3 Instead, I would like to do something like this (except actually functional, hopefully my made up syntax is self explanatory, I'm also going to need a p4 in a different part of my script) FROM departments as d INNER JOIN people as p1 AND p2 AND p3 The reason for having 3 different aliases for the 'people' table is there are 3 different columns in the departments table that contain a person ID corresponding to different positions. If there is a better way to do this, I'd be ok with that too.I'd also like to know how I would use LEFT JOIN instead of inner in that statement above, as I would like to return every row from 'departments' regardless of it finding a corresponding person. (Everything I've tried has thrown an error, so I've just left them all as INNER, which is currently omitting 3 rows from the 'departments' table, as apparently they have no corresponding person).Full SQL statement: SELECT d.`id`, d.`dept`, p1.`name`, p1.`email`, p2.`name` as 'b_name', p3.`name` as 'd_name'FROM departments as d INNER JOIN people as p1 INNER JOIN people as p2 INNER JOIN people as p3WHERE d.`tech_liason_id` = p1.`id` AND d.`backup_tl_id` = p2.`id` AND d.`dept_head_id` = p3.`id`
  2. Err... now I just feel silly, I knew that :/@boen_robot: I'll look in to it.
  3. Alright, still confused :)I've got the following code... which accomplishes roughly nothing. Using print_r()s that I've deleted, the variables $newFolder/$newFile/$newResource seem to be created properly. So that leaves my add_child() method to blame. Anywhere I call print_r() on what should be a class with at least one node, I just get back object with the member array $children being empty. Calling echo_children on any of them also returns nothing.Non-functional code below. class folder { public $name = ''; public $linksIn = 0; public $vipIn = 0; public $linksOut = 0; public $children = array(); public function add_child($child) { //I've tried passing $child by reference as well $children[] = $child; } public function echo_children() { foreach($children as $child) print_r($child); }}function dir_list($startDir) { $fileList = new folder(); $fileList->name = $startDir; $tempArr = scandir($startDir); foreach($tempArr as $item) { if ($item == "." || $item == ".." || $item == "_notes") {} elseif (is_dir($startDir.'/'.$item)) { $newFolder = dir_list($startDir.'/'.$item); $newFolder->name = $item; $fileList->add_child($newFolder); } else { $pathinfo = pathinfo($item); if ($pathinfo['extension'] == 'shtml') { $newFile = new page(); $newFile->name = $item; $fileList->add_child($newFile); } else { $newResource = new siteResource(); $newResource->name = $item; $fileList->add_child($newResource); } } } print_r($fileList); return $fileList; } @wirehopper: Unfortunately I haven't used PHP iterators before. I'm reading around to learn about them now. As best as I can tell, they are more-or-less array wrappers that allow you to use arrayss as sets of a common object type? So you're suggesting I go back to my previous method of containing my folder hierarchy within an array?I'll take suggestions for either method, although I'd prefer the object-tree way, as I am more familiar with using C++ style trees
  4. I've been thinking about this for awhile (alright, 20 minutes), and I can't seem to get my head around this.I'm basically trying to make an object tree; for this project, it happens to be a folder/file hierarchy (in other words, I'm taking a folder, and recreating the tree structure of it and its contents with PHP classes). I already had this working just by recreating it in an array, where keys were folders and entries were the contents. But for what I'm using this for, I needed each node (if I can go back to the object tree line of thinking) to have its own functions. I've done object trees in C++ before, so maybe I'm just thinking about it wrong for PHP, but I'm not sure how else to do this.As best as I can tell, PHP doesn't have pointers, making the methods by which I've done trees not so helpful. However, I haven't quite really wrapped my head around PHP references and how to use them properly, so it is very possible the solution is staring me in the face and I just have to use references, I don't know.What I want is to build a tree out of a class like the one spec'd below. The tricky part is that I need to be able to use the child instances outside of accessing the parent class, so the children nodes can't just be contained within the parent node as my above array method would have done (so if I have an instance 5 levels deep in the tree, I still want to be able to just use a pointer to change that one from my main function).Hopefully the below makes sense. Can anyone offer an explanation? class exampleClass { public $variable = ''; public $children = array(); public function add_child($child) { $children[] = $child; } public function get_child($num) { return $children[$num]; }}***PHP combined C-style psuedocode****$a = new exampleClass;*$b = new exampleClass;*$c = new exampleClass;*$d = new exampleClass;$a->add_child($b);$a->add_child($c);$b->add_child($d);//I now have a basic tree as such// a// / \// b c// \// d*$somePointer = $b->get_child(0);$somePointer->variable = 'variable of -d- is being set here';
  5. First, a couple of set-up arrays to explain the question: --- Base array ---Array ([some_key] = stuff[another_key] = Array ( [second_level] = 2nd stuff [level_key_2] = 7 ))--- Input array ---Array ([another_key] = Array ( [level_key_2] = 1 )) Now for the problem. See the '1' in the Input array -> another_key -> level_key_2? I want to add it to the same key hierarchy in the Base array. (So the '7' should become an '8'). I think I could do this with a stupidly complex set of functions, but I'm hoping someone here could lend me a simpler method.
  6. Alright. I have 2 divs in this image, one of them has float:right applied, along with an 8px margin. The other, coming later in the code, has a set height, but an unset width. I've outlined where the second div edges should be in my mind, and have pointed to the part that shows it is still extending right (the line is part of the background image). How exactly does one force other divs to behave as the text (contained in a <p> tag) does?
  7. Hopefully this code is self explanatory. I have a table with a bunch of cells with divs within, and upon hovering on any one I need that div to disappear and one with and id that just has '_on' added to the id of the original div to become visible (via adding/removing the class 'hidden' that I have set). Aaaaand, it isn't working and I have no idea why. I'm fairly new to jquery, so this could be something rather stupid. Any insights? var $music = jQuery.noConflict();$music(document).ready(function() { $music("#program_links > tr > td > div").hover( function() { var id = this.attr("id"); var newid = "#" + id + "_on"; this.addClass("hidden"); $music("#"+newid).removeClass("hidden"); },function() { var id = $music(this).attr("id"); var newid = "#" + id + "_on"; $music(this).removeClass("hidden"); $music("#"+newid).addClass("hidden"); } ); });
  8. Looking around more on other implementations on the server, I had to do this... var $thing = jQuery.noConflict();$thing(document).ready(function() {... So, yeah, jQuery was included :)I might be back with another question in this thread in a bit, depending on if I get this next piece working right...
  9. I'm working on a simple news ticker that is supposed to just swap an image and text blurb out. I've got the onClick working for the story headers, but I can't get the auto-change working.I ripped a bunch of this out of a different jQuery tutorial that didn't quite apply, so I've probably messed that up somehow.Right now Safari gives me a "TypeError: Result of expression '$' [undefined] is not a function." error at that line in the js file (but allows other functions in the file to run just fine) while FF seems to just ignore the entire file.Safari is finding the error at the first line of this (the $(document) line), and if I delete everything within the function, it is still getting the error, so I'm not sure what is wrong. jQuery is being included elsewhere. $(document).ready(function() { var speed = 5000; var run = setInterval('ticker(0)', speed); $('#news_content').hover( function() { clearInterval(run); }, function() { run = setInterval('ticker(0)', speed); } ); $('#links a').click(function () { //stop the slide show clearInterval(run); //resume the slideshow run = setInterval('ticker(0)', speed); return false; });}); I'd take another simpler solution to this (auto-change script) as well if you know of one.
  10. smartalco

    Php And Oracle

    I have done quite a bit of PHP with MySQL DBs, for which PHP has dozens of functions to help handle. Not so much for Oracle from what I can tell. I'm now working on adding some functionality to an app. The following is how it currently deals with Oracle queries $query = "SELECT events.category_id, TO_CHAR(events.event_date, 'MON') as event_month"; //more to this I cut out$sql->query($query);while($sql->fetch()) { $category_id = $sql->results["CATEGORY_ID"]; $date_month = $sql->results["EVENT_MONTH"]; Just iterating through each item of a single row and writing them to variables.That works just fine for SELECT statements that only return a single row, what I'm doing now returns multiple rows... and I have no idea what to do.I'm want to write to an array, first level is each row, second level is each item from the row.Can anyone help with this?
  11. also, http://www.php.net/manual/en/index.php is the bible, don't try to read the whole thing, thats ridiculous, but it will help you find pretty much anything you need in the documentation
  12. smartalco

    What not to do

    I think this guy pretty much just summed up the entire thread.
  13. Ok that didn't work quite like I had hoped.The show/hide part functions perfectly, but there is a problem with how it displays the tables after they switch from display:none to display:block.Upon un-hiding the table, the browser doesn't figure out how to properly position the cells in the table, instead of spacing all the cells within it evenly (when the width of the table is set), it compacts them to only the width of what is in them, and if that adds up to less width then the table is set at, there is a gap between the right side of the contained columns and the right side of the table itself (I'll take a screenshot if that made no sense)Is there a way to force the browser to figure out the table dimensions properly?edit: I forced widths on every <td> in the table, which seems like a really bad solution, but it is at least mostly working (still changes dimensions by a couple pixel between show/hides, but it is using the entire width of the table, so the gap is gone)
  • Create New...