Jump to content

lucasjay

Members
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

1 Neutral

About lucasjay

  • Rank
    Newbie
  1. In this case, specifically, because it's for a university assignment, and the requirement that's getting me is as follows:"Salesreps have an ID code of which the last four characters give their delivery_id". So while I could select them and get that result, I didn't want to write any queries and instead just have the answer on the table. Maybe you're right though, I guess I could just create a view that combines the two columns into a new one. Still, it truly baffles me that want I was trying to achieve isn't possible at all...
  2. Ok, well I gave that a go - here is my trigger: CREATE TRIGGER salesrep_id_create for insert ON salesrepsFOR EACH ROW set new.salesrep_id = concat(new.srid,new.delivery_id); Where salesreps is the table, srid is an auto-incremented column, and delivery_id is a foreign key. Unfortunately this doesn't work because srid is auto-incremented and doesn't have a value until after the row is inserted. I have tried all the various combinations with various errors as a result: Here I found someone who had the same problem: http://mysqldatabaseadministration.blogspot.com.au/2006/03/mysql-triggers-accessing-value-of-auto.html So I don't think this is going to work Thanks for the suggestion though. I don't really get composite primary keys... Why can't I just make a composite primary key out of srid and delivery_id and display a column that is sriddelivery_id which displays the actual values of the composite keys? It seems odd that they exist but you can't actually see them when you select * from table...
  3. I cant believe how little success I have had in discovering the answer to my problem on Google over the last hours of trawling... I have an ID number (salesrep_ID) that I want to use as the primary key, and I want it to be comprised of another field (delivery_id) and an auto increment number. i.e. delivery id = 1234 salesrep_id = 0011234 ....HOW? Oh god how? It seems the thing to do would be to create a new field that is autoincremented and then make salesrep_ID the composite primary key of the incremented field and delivery_id. But I want this to be displayed when I query "select * from salesreps" (salesreps is the table name): salesrep_ID0011234 NameJohn Smith Address123 Fake St delivery_id1234 This must be simple? I'm so confused My love and adoration for anyone who can help.
  4. Holy crap it worked, using MAMP. Thankyou so much, that was driving me completely insane, and using a server didn't even vaguely occur to me. Hooray! Thanks again for the help
  5. Just tried it on my PC... it doesn't work in IE9 either. Only success in Safari so far...
  6. index.html <html><head></head><body><script type="text/javascript"> xhttp=new XMLHttpRequest(); xhttp.open("GET","books.xml",false); xhttp.send(); xmlDoc=xhttp.responseXML; x=xmlDoc.getElementsByTagName("title"); for (i=0;i<x.length;i++) { document.write(x[i].childNodes[0].nodeValue); document.write("<br />"); }</script></body></html> books.xml: <?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><bookstore><book category="cooking"><title lang="en">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book><book category="children"><title lang="en">Harry Potter</title><author>J K. Rowling</author><year>2005</year><price>29.99</price></book><book category="web"><title lang="en">XQuery Kick Start</title><author>James McGovern</author><author>Per Bothner</author><author>Kurt Cagle</author><author>James Linn</author><author>Vaidyanathan Nagarajan</author><year>2003</year><price>49.99</price></book><book category="web" cover="paperback"><title lang="en">Learning XML</title><author>Erik T. Ray</author><year>2003</year><price>39.95</price></book></bookstore>
  7. Sorry, yes, it works in the tryit editor in opera...
  8. It can't be the length property, as like i said I took away the for loop from the example just to test, and that's how I get opera to display an error, instead of nothing at all. The error is in this line: document.write(x[0].childNodes[0].nodeValue); in that for some reason the node from the xml file, which is simple text "cannot be converted to object". It works in the TryIt editor, and in Safari. I would try more browsers, but for my purposes I'm really mostly interested in Opera. Just to clarify, in the example, and in my code above, there is a simple xml file with some book information, and we want to display a list of all the books in the xml file, hence the for loop. But to test a simpler version, literally all I want to do, is get the title of the first book. So getElementsByTagName("title") gets the title tags, which we store in the variable x. Then the code document.write(x[0].childNodes[0].nodeValue); gets the first title tag (x[0]) then the text inside that tag (childNodes[0]) and returns the nodevalue, which should be the title of the first book in the xml file. x[0], to my understanding, should simply contain the text "title", but 'cannot be converted to object', which i just plain don't get. (Like I said, I'm a beginner). The code works fine in Safari, so theres obviously some element that is incompatible with opera, but I don't know of any alternative methods.
  9. Must be an opera thing again, the code in its original form is on this page: http://w3schools.com/dom/dom_nodes_access.asp I've just put it all on the same HTML file.
  10. Hi everybody,I've been working my first website, and I came to a section where I wanted to get data from an XML file and display it on the web page. So I followed the XML and XML DOM tutorials, but I've hit a maddening wall, thanks to Opera. ?script?xhttp=new XMLHttpRequest();xhttp.open("GET","books.xml",false);xhttp.send();xmlDoc=xhttp.responseXML;x=xmlDoc.getElementsByTagName("title"); for (i=0;i?x.length;i++) {="" document.write(x.childnodes[0].nodevalue);="" document.write("?x.length;i++);{ document.write(x.childNodes[0].nodeValue); document.write("?br /?");}?/script? This is the code taken straight from the tutorial, and I've saved "books.xml" from there just to check I wasn't making any of my own errors. It works fine in Safari and displays the book list, but nothing displays in Opera. It doesn't throw up any errors either, but when I swap the for loop in the code to the simpler document.write(x[0].childNodes[0].nodeValue); I get the error in the inspector: Uncaught exception: TypeError: Cannot convert 'x[0]' to object. I've done everything I could think of, but no luck, and I cannot fathom what the problem might be. Please help! Regards,Luke
  11. I don't know why that didn't post properly... seems this forum doesn't like tags? I'm going to rewrite, replacing all the tags with question marks...
  12. Hi everybody,I've been working my first website, and I came to a section where I wanted to get data from an XML file and display it on the web page. So I followed the XML and XML DOM tutorials, but I've hit a maddening wall, thanks to Opera. xhttp=new XMLHttpRequest(); xhttp.open("GET","books.xml",false); xhttp.send(); xmlDoc=xhttp.responseXML; x=xmlDoc.getElementsByTagName("title"); for (i=0;i
×
×
  • Create New...