Jump to content

Sharkadder

Members
  • Content Count

    119
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Sharkadder

  • Rank
    Member
  1. Hi there, It is ok i sorted this now, happens that i had a parent outcome id field in my table and so each sub-outcome had a parent id which was linked to the main outcome ID. All i did was get the main outcome ID's from the database in ascending order, and then search for each sub-criteria who had that main outcome ID as their parent...then i was able to capture the information in the order i needed. Many thanks, Mark
  2. Hi there, I have an SQL table which has a field within it that holds data within a row. The field holds data for outcomes which can be listed as follows: Outcome 1 1.1 1.2 Outcome 2 2.1 2.2 1.3 Outcome 4 4.1 4.2 Outcome 3 3.1 1.4 etc. Basically, they are not in order as people have been typing them into the database table in a random order. Is there a way i can get it so that it shows everything to do with outcome 1 under outcome 1 etc. once i pull the rows from the database? e.g. Outcome 1 1.1 1.2 1.3 1.4 Outcome 2 2.1 2.2 etc. I have tried assending and decsending orders but they obviously show the numeric data first. Currently i am having to use several foreach loops in PHP to sort out the ordering and would like a more efficient way of doing this. Was not sure if i could do a command in MySQL direct. I am using MySQL 5.0 Many thanks
  3. Thanks dude i have added that code in now. I have got it all working and even the .value is now working which is really good since i modified the code to what you said. If i stumble across any other problems i shall post on here but i think it is sorted now, going to do some testing tomorrow on my script :-). Mark
  4. Hi dude, Thank you once again for the reply. Basically i have a loop which loops through all of the table rows from within a table, each iteration of the loop uses the number i which increments each time the loop goes around. This is why i have code such as: document.getElementsByTagName("tr") <---the i here is the TR element number for whichever iteration the loop is on. So if we look at what i am trying to achieve, I am trying to change the id and name of a select element and three input elements within TD tags using Javascript, alternatively i could use jQuery. I cannot use any server side languages as i allow people to add in a new row to the table by clicking on a button and so Javascript or Jquery is needed to re-number all of the ID's. e.g. i have a row which contains 4 cells, 1 is a select drop down box and the other three all contain an input box. Do you think that you could give me an example of how this could be achieved, and code which will work when using internet explorer? All i need to do is get the element from inside the TD tag and replace the ID and Name value from within it. Is there any way i can make use of GetElementbyID or GetelEmentByName and change the ID or name that way without innerHTML? Many thanks and hope you can help me with this problem..i try to stay away from Javascript and i mostly program in PHP but this has to be client side without needing to refresh the page, Mark
  5. Hi there and thank you for the reply. I have tried just about everything and silly internet explorer keeps kicking back error messages! Beginning to get frustrating now. Do you know of any function where i can pass it the tag name i am wanting to send HTML to e.g."document.getElementsByTagName("tr")" and to then replace the HTML to update the table row without innerHTML I have tried the following and it just does not work! //inside the head of the document function replaceHtml(el, html) { var oldEl = typeof el === "string" ? document.getElementById(el) : el; /*@cc_on // Pure innerHTML is slightly faster in IE oldEl.innerHTML = html; return oldEl; @*/ var newEl = oldEl.cloneNode(false); newEl.innerHTML = html; oldEl.parentNode.replaceChild(newEl, oldEl); /* Since we just removed the old element from the DOM, return a reference to the new element, which can be used to restore variable references. */ return newEl;}; //inside the body newHTML = document.getElementsByTagName("tr")[i].innerHTML.replace(document.getElementsByTagName("tr")[i].cells[j].childNodes[0].id,nameandid).replace(document.getElementsByTagName("tr")[i].cells[j].childNodes[0].name,nameandid).replace(document.getElementsByTagName("tr")[i].cells[j].childNodes[2].id,calendarid).replace(document.getElementsByTagName("tr")[i].cells[selecttdid].childNodes[0].name,selectname); //work around for innerHTMLdocument.getElementsByTagName("tr") = replaceHtml(document.getElementsByTagName("tr"),newHTML); IE just states an invalid procedure call on the line: var oldEl = typeof el === "string" ? document.getElementById(el) : el; Think you could amend my code to maybe work or perhaps tell me an alternative function. Many thanks, Mark
  6. Hi there, I have recently been trying some code out to replace the innerHTML contents from within a table row, i am now to discover that Internet Explorer which a lot of people still use insists of making innerHTML properties read only, although the code works flawlessly in Firefox and Google Chrome. The code i have currently got is shown below: document.getElementsByTagName("tr").innerHTML = document.getElementsByTagName("tr").innerHTML.replace(document.getElementsByTagName("tr").cells[j].childNodes[0].id,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[0].name,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[2].id,calendarid).replace(document.getElementsByTagName("tr").cells[selecttdid].childNodes[0].name,selectname); As you can see from the above code i am trying to tell a tag name TR which has an index of i innerHTML to change to itself but with some things replaced. You don't need to know what i am replacing inside the code as that code is all fine. What i would like to know is, what work around do i have to change the innerHTML using Javascript or JQuery? Some people have said to stick it into a Div tag but the problem is that the table is inside of a form and i am sending the elements from a form to a different page and so i would rather keep it inside the table row. I have also read that innerHTML can be used to modify specific cells from within a table i.e. contents inside a TD tag. Does anybody know how i can modify my code accordingly so that the debugger stops spitting out the "operation" error messages when i put debugging on due to trying to write to innerHTML? I have also tried using outerHTML and didn't seem to work either: document.getElementsByTagName("tr").outerHTML.replace(document.getElementsByTagName("tr").innerHTML,document.getElementsByTagName("tr").innerHTML.replace(document.getElementsByTagName("tr").cells[j].childNodes[0].id,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[0].name,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[2].id,calendarid).replace(document.getElementsByTagName("tr").cells[selecttdid].childNodes[0].name,selectname)); You will notice in the above i am trying to replace the innerHTML of an element(a TR tag at number i) with some things removed and again, because i am trying to modify the innerHTML...it was a no go again. Finally i have tried to modify a value property in internet explorer and this time it spits out a 5007 error saying that it is unable to set the value of the property, anybody know how i can get around this? My code again for this is below to what i currently tried: document.getElementById("unitstartdate"+totaltablerows).value = startdate; The ID's do exist and again this code worked fine in firefox and chrome, just not IE. I think i am more after a work around for both situations rather than you understanding what i am actually trying to replace etc. as the replace part of the code is fine, just will not write to HTML in Internet explorer using innerHTML, outerHTML or change a value of an element as mentioned. Any ideas are great. Mark
  7. Hi, I solved the problem with the following function, although it does require a loop. Not sure if there is a more efficent way but my page seems to load fine with it: //dropdown is the dropdown you selected and theForm is the formfunction checkselected(theForm, dropdown){for (i=0; i<theForm.length; i++) { //myval.options[myval.selectedIndex].innerHTML if (theForm.elements[i].type == "select-one") { if (dropdown.options[dropdown.selectedIndex].innerHTML == theForm.elements[i].options[theForm.elements[i].selectedIndex].innerHTML && theForm.elements[i].name != dropdown.name) { alert("You have already selected this unit. Please choose a different one."); //change index on selected dropdown back to zero dropdown.selectedIndex = 0; } }}}
  8. Hi there, I have 10 drop down boxes on a page where people can select some units they wish to study. Obviously people can pick more than one unit and so i want to avoid them from picking the same unit twice in each of the drop down boxes. I have looked into the disable function on drop down boxes but cannot figure out how i would go about disabling a drop down selection entry using Javascript. So far i have looked at the following jquery function below but it will not work on my php page as i do not have access to the head of the document on the platform i am on and just the body: $('select').change(function() { var ary = new Array(); $('select option:selected').each(function() { if ($(this).val().length > 0) { ary.push($(this).val()); } }); $('select option').each(function() { if ($.inArray($(this).val(), ary) > -1) { $(this).attr('disabled', 'disabled'); } else { $(this).removeAttr('disabled'); } });}); The example above is the sort of thing i am after but having studied the code, without it being in the head of the document it will not work and so it does not work when i change entry in the dropdown list. Does anybody have any modifications to the code or examples i can use to find out the values of all other dropdown's on a form and to then disable an index in the others where one is already selected on that index? Obviously i would need something to enable selections again. Even an alert box stating that the unit has already been picked and resetting back to original value would do. Many thanks, Mark
  9. Hi there, I have been looking up on how to use SOAP in relation to php and have managed to hit a bit of a snag with it. Basically on my server i get some information which is presented in xml format from sharepoint. I then wish to access this data from a php file on another server and print it out onto the screen. I have heard using a soap call is the best method for this. The problems i am having are as follows: Gaining authorisation to the xml file i which contains the soap contents i.e. how to log in with username and password Reading the soap content in php to capture some data and print it out Shown below is a copy of my data which is in an xml format: <xml><s:Schema id="RowsetSchema"><s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30"><s:AttributeType name="ows_DocIcon" rs:name="Type" rs:number="1"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_LinkFilename" rs:name="Name" rs:number="2"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_Created" rs:name="Created" rs:number="3"><s:datatype dt:type="datetime" dt:maxLength="8"/></s:AttributeType><s:AttributeType name="ows_Author" rs:name="Created By" rs:number="4"><s:datatype dt:type="string" dt:lookup="true" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_CheckoutUser" rs:name="Checked Out To" rs:number="5"><s:datatype dt:type="string" dt:lookup="true" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows__x007b_064b332a_x002d_4d9e_x002d_4e7e_x002d_8cf9_x002d_227b6c7972db_x007d_" rs:name="Learner Name" rs:number="6"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_StartDate" rs:name="Start Date" rs:number="7"><s:datatype dt:type="datetime" dt:maxLength="8"/></s:AttributeType><s:AttributeType name="ows_JobTitle" rs:name="Job Title" rs:number="8"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_Region" rs:name="Region" rs:number="9"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_Learner_x0020_Email" rs:name="Learner Email" rs:number="10"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType></s:ElementType></s:Schema><z:row ows_DocIcon="xml" ows_LinkFilename="learner_name.xml" ows_Created="2012-03-20 16:26:24" ows_Author="17;#**** *****" ows__x007b_064b332a_x002d_4d9e_x002d_4e7e_x002d_8cf9_x002d_227b6c7972db_x007d_="****** ******" ows_StartDate="2012-03-20 00:00:00" ows_JobTitle="Director" ows_Region="Durham" ows_Learner_x0020_Email="******@hotmail.co.uk"/></rs:data></xml> Ok so that is the code for one learner record which i am wanting to parse in php...all i want to know is, what do i do to get the learner e-mail address? (the one with the value xxxxx@hotmail.com from the page which requires authorisation to view it. So far i have tried the following with no luck (hashed out the main part of url as contains confidential material): <?php$xml = simplexml_load_file("http://*********.co.uk:8088/OPS/_vti_bin/owssvr.dll?Cmd=Display&List={6A2E72AB-8F77-4B94-A7FA-DB00527CEFB4}&XMLDATA=TRUE");echo $xml->AttributeType() . "<br />";foreach($xml->children() as $child){echo $child->AttributeType() . ": " . $child . "<br />";}?> I have also tried the following php code to display the learner name field (that is the name starting with ows__ with letters, underscores and numbers as shown below). it just says failed to load external entity which i am unsure about: <?php$client = new SoapClient("http://*********.co.uk:8088/OPS/_vti_bin/owssvr.dll?Cmd=Display&List={6A2E72AB-8F77-4B94-A7FA-DB00527CEFB4}&XMLDATA=TRUE", array(trace=>true, 'login'=>"*******", 'password'=>"*****"));$res = $client->row(array('ows__x007b_064b332a_x002d_4d9e_x002d_4e7e_x002d_8cf9_x002d_227b6c7972db_x007d_'=>5));print $res;?> As you can see i have hashed all of the confidential details out but if somebody could maybe correct my php code so that i can gain access to the file, parse an element from the xml and then display it on the screen then that would be great. Obviously i do have more records but only displayed the first one for demonstration purposes. I also have access to the request and response generated by the server if you wish to see them or maybe point me in the direction on how i can use them instead to print out the values in php. Many thanks, Mark
  10. yeah i knew that much but just wodnered if it was good practise.anyways, cheers dude.
  11. ok i decided to try on a different person in case of data input error but the same thing occured. The name John O'Shea was tried and it worked well and it now works for both names.I looked at your code and the apostrophe was the same character, i then looked at what you said and the result now shows. Some of the suggested code must have been wrong as an error on my part but it now works well. Do you recommend using a slash before the apostrophe in the raw database or leave it without one?Thanks for all of the help and suggestions...i am not sure if i need the code which was first suggested for my post variables and if i can cut down the code then let me know but the problem is now solved.The name now shows
  12. Ok it still says no records found. The name is definately in the database and so i'm thinking the apostrophe isn't matching the one from the raw database. I have done as justsomeguy says and taken off the condition to search a category but it just says no results. If i change the name for one without an apostrophe in then it finds the name and so it's got to be to do with removing the apostrophe.Here is the current code: if (get_magic_quotes_gpc()) { $_GET = fixMagicQuotes($_GET); $_POST = fixMagicQuotes($_POST); $_REQUEST = fixMagicQuotes($_REQUEST); $_COOKIE = fixMagicQuotes($_COOKIE);}if (isset($_POST['search'])){ $searchterm = $_POST['SearchTerm']; $searchterm = trim(rawurldecode($searchterm)); #$searchterm = str_replace("\\","",$searchterm); print $searchterm; #$searchterm = trim(utf8_encode($searchterm)); $searchcategory = $_POST['Category']; $characterremove = array("/"," "); $searchcategory = str_replace($characterremove,"",$searchcategory); $con = mysql_connect('h50mysql107.secureserver.net','sensiswos','Sens1sw0s'); @mysql_select_db("sensiswos",$con) or die(mysql_error()); $searchcategory = mysql_real_escape_string($searchcategory, $con); $searchterm = mysql_real_escape_string($searchterm, $con); $playermanagersearch = mysql_real_escape_string($playermanagersearch, $con); mysql_query("SET NAMES utf8"); #$query="SELECT * FROM FootballPlayers WHERE lower($searchcategory) LIKE lower('%$searchterm%') AND lower(PlayerManager) LIKE lower('$playermanagersearch') COLLATE utf8_bin ORDER BY Name asc"; $query = "SELECT * FROM FootballPlayers WHERE lower(Name) LIKE '%Adam O\'Donnell%' AND lower(PlayerManager) LIKE '%' COLLATE utf8_bin ORDER BY Name asc"; $searchterm = str_replace(array('%', '_'), array('\\%', '\\_'), $searchterm); $playermanagersearch = str_replace(array('%', '_'), array('\\%', '\\_'), $playermanagersearch); print $query; $result=mysql_query($query) or exit(mysql_error()); print $result; $num=mysql_numrows($result); print $num; mysql_close(); updated printed query, result and number of rows count is: SELECT * FROM FootballPlayers WHERE lower(Name) LIKE '%Adam O\'Donnell%' AND lower(PlayerManager) LIKE '%' COLLATE utf8_bin ORDER BY Name ascResource id #30
  13. ok i added in the slight error check modification and still nothing. I get no errors from the search, just it doesn't appear to find anything.the record definately exists and is definately in the database without a \ before the apostrophe. What else do you think i could try?
  14. ok i tried that and it never worked, the query now shows this: Adam O'DonnellSELECT * FROM FootballPlayers WHERE lower(Name) LIKE lower('%Adam O\'Donnell%') AND lower(PlayerManager) LIKE lower('%') COLLATE utf8_bin ORDER BY Name asc
  15. Your code didn't work, still says no results found although i am no longer getting the numrows error. In fact your code doesn't work for any person in my database with or without apostrophe, so it must be going wrong somewhere. Below is a copy of my updated code and query, i moved the $searchterm and $playermanager = str_replace codes down a bit as no results were showing for anything when they were in the position you said: if (get_magic_quotes_gpc()) { @array_walk_recursive($_GET, 'stripslashes'); @array_walk_recursive($_POST, 'stripslashes'); @array_walk_recursive($_REQUEST, 'stripslashes'); @array_walk_recursive($_COOKIE, 'stripslashes');}if (isset($_POST['search'])){ $searchterm = $_POST['SearchTerm']; $searchterm = trim(rawurldecode($searchterm)); #$searchterm = str_replace("\\","",$searchterm); print $searchterm; #$searchterm = trim(utf8_encode($searchterm)); $searchcategory = $_POST['Category']; $characterremove = array("/"," "); $searchcategory = str_replace($characterremove,"",$searchcategory); $con = mysql_connect('h50mysql107.secureserver.net','sensiswos','Sens1sw0s'); @mysql_select_db("sensiswos",$con) or die(mysql_error()); $searchcategory = mysql_real_escape_string($searchcategory, $con); $searchterm = mysql_real_escape_string($searchterm, $con); $playermanagersearch = mysql_real_escape_string($playermanagersearch, $con); mysql_query("SET NAMES utf8"); $query="SELECT * FROM FootballPlayers WHERE lower($searchcategory) LIKE lower('%$searchterm%') AND lower(PlayerManager) LIKE lower('$playermanagersearch') COLLATE utf8_bin ORDER BY Name asc"; $searchterm = str_replace(array('%', '_'), array('\\%', '\\_'), $searchterm); $playermanagersearch = str_replace(array('%', '_'), array('\\%', '\\_'), $playermanagersearch); print $query; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close();} So i again type in Adam O'Donnell and it just says that no results are found. If i put the "$searchterm = str_replace(array..." and "$playermanagersearch = str_replace(array..." code before the query then it doesn't find anything, not even people who have no apostrophe in their name. Where it is in the code above i am back to the problem i had before, fidns names but not people with apostrophe in their name.the printed search term and query with the way the code is above now looks like this: Adam O\'DonnellSELECT * FROM FootballPlayers WHERE lower(Name) LIKE lower('%Adam O\\\'Donnell%') AND lower(PlayerManager) LIKE lower('%') COLLATE utf8_bin ORDER BY Name asc Any further help would be apprechiated on locating players with apostrophes in their names.
×
×
  • Create New...