Jump to content

jenkins

Members
  • Posts

    26
  • Joined

  • Last visited

jenkins's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Psycho, Thanks for your reply. Your solution works well, but I don't think I would have ever solved it like this I can get the data as follows from a xml file. When I tried directly from the xml file I kept getting an error when parsing. Would this be easier: foreach ($result as $catID) { $catalogID = $catID->CAT_ID; $date = $catID->CAT_DATE; } Thanks again!
  2. Hi, I have the following array and would like to loop through it and check if there are duplicate catalogIDs, if yes, I would like to compare the dates and choose the earliest date. In the following array: catalogID 1257 is there two times. I need earliest date, which is 2013-09-03 catalogID 1340 is there three times. I need earliest date, which is 2013-09-04 Array ( [0] => 1159, 2013-09-03 [1] => 1157, 2013-09-03 [2] => 1257, 2013-09-03 [3] => 1257, 2013-09-13 [4] => 1340, 2013-09-04 [5] => 1335, 2013-09-03 [6] => 1340, 2013-09-13 [7] => 1410, 2013-09-03 [8] => 1340, 2013-09-18 ) Is it easier to add all the unique catalogIDs with the earliest date to a new array or remove the duplicate catalogIDs with the late dates from the current array? I have tried a foreach loop and a for loop with counter but I'm not able to do this. Any ideas? Thanks!
  3. Hi TheLetterE, Thanks for replying. I think you are correct about the forum for this posting. Almost 4000 views before your reply I will checkout your suggestions. I decided to put the statistics and graphs in a floating div that can be moved around the screen. The contents of the div are updated when actions are performed on the main page. I have to move it around depending on what I want to see/do on the main page, but it solves the problem, at least for now. Thanks again.
  4. Hi Andy, Apologies for the late reply. I did get this working Thanks for all your help.
  5. Yes I added the square brackets after the $courses variable. The output is: Array ( [0] => SimpleXMLElement Object ( [0] => 1101 ) )
  6. Thanks Andy. It's a little better But it is still not getting the all the textbooks I'll keep working on it. The output is now: [0] => Array ( [id] => 1101 [name] => Biology101 [text_books] => Array ( [0] => biology textBook title 1 ) )
  7. Thanks for helping me Andy. I've modified my code as you suggested. My output now looks like this: [0] => Array ( [id] => SimpleXMLElement Object ( [0] => 1101 ) [name] => Biology101 [text_books] => Array ( [0] => SimpleXMLElement Object ( [0] => biology textBook title 1 ) ) )
  8. Hi requinix, Thanks for your reply. I'm getting the data like this: $xml = new SimpleXMLElement($res->GetCourseInfo->any); $result = $xml->xpath('//Students');
  9. Hi all, I have a wsdl (xml) file that provides course number, name and textbook. I am using foreach ($result as $course) to get courseID so that I can get the courseName and textBook for each course. Some courses have more than one textBook so the course is listed multiple times. For example, if a course has 3 textBooks, it is displayed 3 times, like so: CourseID CourseName TextBook 1101 Biology101 biology textBook title 1 1101 Biology101 biology textBook title 2 1101 Biology101 biology textBook title 3 I would like to list the course once and then check for multiple textBooks and display all textBooks at the same time, as follows: CourseID CourseName TextBook 1101 Biology101 1. biology textBook title 1 2. biology textBook title 2 3. biology textBook title 3 I have put the information into an array which displays like this: Array ( [0] => 1101 , Biology101 , biology textBook title 1 [1] => 1101 , Biology101 , biology textBook title 2 [2] => 1101 , Biology101 , biology textBook title 3 [3] => 1106 , Math106 , math textBook title 1 [4] => 1106 , Math106 , math textBook title 3 ) What is the best way of accomplishing this? Should I use an array to add all the information or try another approach? Thanks for any suggestions.
  10. Hi all, I am redesigning/developing an existing web-based application that needs a lot of space on the screen. If the application runs on a 30-inch iMAC it displays nicely. However, not everyone has a monitor this large. It does not display well on small monitors or projectors, even when the resolution is changed. The interface/page has two parts. The left side shows statistics, graphs, etc. and changes/updates based on actions/events on the right side of the page. Making the interface items smaller is not really an option as it is almost already too small. The left side has about 80 rows of data plus graphs. Currently the right side has 25 divs that are about 300px x 300px and the divs are laid out as 5 x 5, so there is already a lot of vertical scrolling. However, sometimes the number of divs on the right side is 20 or 30. Aside from horizontal scrolling, does anyone have any suggestions? Thanks very much.
  11. Actually, when a checkbox is checked the item (and if necessary its parent) are copied from the nodes table to the roleMenu table - that is fine. It just doesn't echo permissionGranted the first time through if the parent has not been previously added. Somewhere when I am checking if the parent_id has not been added to the roleMenu and the function is called again to add it there is an error. When an item has been added, it is displayed like this: Thanks again for any help!
  12. Hi all, I have the following code to add the id and parent_id of a menu item from one table (nodes ) to another table (roleMenu ) when a checkbox is checked in the menu options . If successful the response is permissionGranted (sent via ajax). I am using a recursive function to do this. The problem is if a child is added (checkbox is checked) where the parent was not previously added, both the child and parent menu items are added but the response is not echoed. I have attached images of the nodes table, roleMenu table and the menu of checkbox options. Can anyone help with my code below? - or - if you think of a better way to do this I am open to suggestions. I've worked on this for several hours but no luck. Any help would be greatly appreciated. Thanks. if ($action == "grantAccess") { function addMenuItems($userRoleValue, $pageIdValue) { include ('include/dbconnect.php'); try { $pdo = new PDO ("mysql:host=$dbhost;dbname=$dbname","$dbusername","$dbuserpass"); } catch (PDOException $e) { echo "Failed to get DB handle: " . $e->getMessage() . "\n"; exit; } $queryRoleParents = $pdo->prepare("SELECT id, parent_id FROM nodes WHERE id = \"$pageIdValue\""); $queryRoleParents->execute(); while($row = $queryRoleParents->fetch()) { if($row['parent_id'] == 0) { $queryRoleItem = $pdo->prepare("SELECT * FROM roleMenu WHERE menuid = \"$pageIdValue\" AND role = \"$userRoleValue\""); $queryRoleItem->execute(); $countRoleItem = $queryRoleItem->rowCount(); if($countRoleItem == 0) { $grantPageAccess = $pdo->prepare("INSERT INTO roleMenu (rmid, role, menuid, parent_id) VALUES ('', \"$userRoleValue\", \"$pageIdValue\", ".$row['parent_id'].")"); if ($grantPageAccess->execute()) { echo "permissionGranted"; } else { echo "permissionFailed"; } } } else { $queryRoleItem = $pdo->prepare("SELECT * FROM roleMenu WHERE menuid = \"$pageIdValue\" AND role = \"$userRoleValue\""); $queryRoleItem->execute(); $countRoleItem = $queryRoleItem->rowCount(); if($countRoleItem == 0) { $grantPageAccess = $pdo->prepare("INSERT INTO roleMenu (rmid, role, menuid, parent_id) VALUES ('', \"$userRoleValue\", \"$pageIdValue\", ".$row['parent_id'].")"); if ($grantPageAccess->execute()) { echo "permissionGranted"; } else { echo "permissionFailed"; } addMenuItems($userRoleValue, $row['parent_id']); } } } } return addMenuItems($userRoleValue, $pageIdValue); }
  13. Hi again, I'm not sure if it is acceptable to return to this previous post or start a new one. I have since changed my approach for the dynamic menu than the one noted above. The current menu system works better for me in regards to creating menu items. However, assigning page permissions to a role is challenging. I have a page that displays the hierarchy tree and on clicking a submenu item I would like to have the parent automatically checked. Since the submenus can go deep several levels I think I need a recursive function to accomplish this. I would also like to do this using jQuery/ajax. And yet another challenge is when I edit the permissions for a role - if permissions have been previously set, I would like to have those check boxes populated. Permissions for each role will be saved in a dbTable. I have attached some screenshots of the menu and the dbTable of the menu items. Any advice on how to go about this? Any sample code? Thanks! Much appreciated.
  14. Hi, I need to implement a function that will allow a user to add a <select> (dropdown) box when clicking a button and be able to keep adding a <select> when clicking the button. I am totally new to jQuery but this is what I have so far: <label for="characteristic" id="characteristic_label">Add Characteristic</label> <input type="button" id="buttonToAddChar" value="Add" style="cursor:pointer;" /> <div id="newCharacteristic" style="display:block; width:100px;"></div> <script> $("#buttonToAddChar").click(function () { var newChar = $("<select/>"); $(newChar).append("<option><?PHP echo "Select from list"; ?></option>"); $("#newCharacteristic").append(newChar); }); </script> This does work (screenshot attached) but I need to add the following features: 1. The options for each <select> dropdown should come from a mySQL query (and each additional <select> added should not contain the option chosen in previous <select> dropdowns) 2. Add the option for a user to remove a <select> previously added (I think another function, right?) 3. Submit/save the option chosen in each <select> to a mySQL table (I can do this using a form, but what is the best way to get the option chosen from each dropdown?) Am I going in the right direction? How difficult is this going to be for a jQuery newbie? Any help would be greatly appreciated. Thank you!
  15. Hi Kicken, Sorry for the delayed reply. I'll give this a try and see what happens Thanks for your help!
×
×
  • 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.