LucasDavenport Posted February 20, 2007 Share Posted February 20, 2007 I am fairly new to PHP programming, but not OO programming. I inherited a web app (long story involved there) with a mySQL back-end supplying the data. The program is fairly well written and I have been tasked with making upgrades and mods to the app. The problem I am having is altering a function that pulls information from the database and puts it into an array to be displayed on a search results screen. The function is: //Function:: s_dept_chair //Purpose:: returns name of anyone who is a chair of a department of type $dept_id function s_dept_chair($dept_id) { if(is_numeric($dept_id)) { $this->query = "SELECT s1.*, ins_name FROM ". "institution, (SELECT person.* FROM person, dept_ins, dept_ins_chair ". "WHERE person.pers_id = dept_ins_chair.chair_id ". " AND dept_ins_chair.dept_ins_id = dept_ins.dept_ins_id ". " AND dept_id = $dept_id ". " ORDER BY person.pers_lastname, person.pers_firstname) s1". " where s1.ins_id = institution.ins_id"; database::query(); } } The page code used to display the array elements is: if(isset($chairs)) if(!empty($chairs)) { foreach($chairs as $chair) { echo "\t<p>\n"; //Removed Until Prefixes are fixed //$out = $prefix_array[$x['arr_prefix']]; echo "<strong>Name:</strong>"; echo "\t\t<a href=\"index.php?action=person_info&pers_id=$chair[pers_id]\">\n"; echo "\t\t\t$chair[pers_lastname], $chair[pers_firstname]"; echo "$chair[pers_middlename] <br />"; echo "\t\t</a>\n"; echo "<strong>Title:</strong>"; echo "\t\t$chair[pers_title]<br/>\n"; echo "<strong>Institution:</strong>"; echo "\t\t$chair[ins_name]<br /> \n"; echo "<strong>Department:</strong>"; echo "\t\t$chair[dept_ins_name] <br />"; echo "<strong>BS:</strong>"; echo "\t\t$chair[bslabel] <br />"; echo "\t\t<strong>Work Phone:</strong> $chair[pers_wphone]<br/>\n"; echo "\t\t<strong>Email Address:</strong>\n"; $emails = explode('|', $chair["pers_emails"]); foreach ($emails as $x){ echo "\t\t$x<br/>\n"; } echo "\t</p>\n"; } I amended the SQL query to add the institution name. Likewise I added the $chair[ins_name] to the loop to display the intitution name with each record. however, the problem i am having is that the institution doesn't display. It's as if the query isn't pulling up the ins_name field from the function I altered previously. When I view the page, the institution field is blank. I added a fake label called BS and it is doing the same thing as the real field, but I can't figure out why it doesn't have the information it should. What am I missing? If i need to provide more info, I can . . . any suggestions? Link to comment https://forums.phpfreaks.com/topic/39347-array-and-variable-question/ Share on other sites More sharing options...
emehrkay Posted February 20, 2007 Share Posted February 20, 2007 im trying to understand why the query is structured the way that it is, but try institution.ins_name in place of ins_name Link to comment https://forums.phpfreaks.com/topic/39347-array-and-variable-question/#findComment-189787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.