GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

COMP233

Cherese Eriepa Englisch 43 Karten

Karten in diesem Stapel (43)

  1. 1how to get values from a URL?use the $_GET method and use the url variable
    eg: url: index.html?variable=value
    we use $_GET['variable'] to get the value
  2. 2SQL: SELECT statementIs used to query a database.
    SELECT * FROM table_name;
    SELECT column_name, column_name
    FROM table_name;
    SELECT * column_name, column_name
    FROM table_name
    WHERE column_name1 = value1;
    column_name2 = value2;
  3. 3the ` <-- Backquote in mySQLSELECT `orderNo`, `customerID` from `order`
  4. 4mySQL datatypesEach column must have a datatype
    eg: VARCHAR, BOOLEAN, CHARACTER
  5. 5Using Select QueriesGets customers who are in Auckland
    SELECT `givenName`, `surName`
    FROM `customer`
    WHERE `city` = `Auckland`;
    Order number of orders which have more than 30 items
    SELECT `orderNo`
    FROM `order`
    WHERE `numOfItems` > 30;
  6. 6SELECT DISTINCT `column_name` FROM `table_name`The SELECT DISTINCT query returns all the distinct values
  7. 7SELECT FROM ORDERwill sort all the data in the column use
    ASC|DESC
    for ascending|descending order
  8. 8count(*)Returns the number of rows in the result
  9. 9min(column_name)to get the minimum value in the column
  10. 10max(column_name)get the maximum value in the column
  11. 11sum(column_name)get the sum of all the values in the column
  12. 12avg(column_name)get the average of all the values in the column
  13. 13Updating the databaseUPDATE table_name
    SET column1=value1, column2=value2
    WHERE some_column=some_value;
    UPDATE `customer`
    SET `GivenName` = `Christie`
    WHERE `customerID`=1002;
  14. 14mysqli_connect()make a connection to a specified mySQL server using the given username, password and database
  15. 15mysqli_query()issue an SQL statement
  16. 16mysqli_fetch_assoc()get one row of results
  17. 17mysqli_close()close the connection
  18. 18Retrieving data from a table1.Establish a connection to the database
    2.Run a query
    3.Receive the data from the query
    4.Close the connection
  19. 19How do you establish a connection to the database?$connection = mysqli_connect($servername, $username, $password, $database);
  20. 20How do you run a query?$result = mysqli_query($conn, $query, $resultmode);
  21. 21How do you receive the data from the query?$row = mysqli_fetch_assoc($result);
  22. 22How do you close the connection to the database?mysqli_close($conn);
  23. 23How do you display the data in a table (php)?';
    echo $row['CustomerID']. " ";
    echo $row['Surname']. " ";
    echo '
    ';
    }
    mysqli_close($conn);
  24. 24mysli_connect_error()if the connection cannot be established mysqli_connect will return FALSE. In such a case display an error message to the user
    if($conn ==== FALSE) {
    die("ERROR".mysqli_connect_error());
  25. 25Inserting data into a table from php$query = "INSERT INTO `customer`(`customerID`, `Surname`, `Firstname`, `city`, `phone`, `email`) VALUES ($id, $sirname, $firstname, $city, $phone, $email);
  26. 26Display data in a formif(isset($_GET) {
    $variable = $_GET("form_item_name");
    }
  27. 27Updating records in a databaseUPDATE.. SET.. WHERE
    identify the row to change via the WHERE condition SET a list columnname=value pairs to specify data values
  28. 28DOM?Document Object Model
  29. 29DOM........Javascript gives you the ability to completely change all aspects of the webpage after it's loaded in the browser.
    What gives JS this power over a webpage is the Document-Object-Model(DOM)
    DOM is a tree like representation of the webpage along with an API
    The W3C defines the DOM as
    - a platform and language neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents
    A web browser parses the HTML representation of a page and constructs a corresponding representation in the form of an internal data structure
    This structure is made accessible to JS code via the DOM
    A simple view of this is that the implicit hierarchical (parent>child) relationships of nested elements in the HTML are turned into an explicit hierarchical (tree-like) data structure
    So the HTML and DOM are alternative representations of the same thing
  30. 30DOM hierarchyFor the document to be properly represented it also needs
    -the entire document including the doctype declaration
    - the content of elements (in this case the text in the paragraphs and the link)
    --Names and values of all attributes
    - style representation
  31. 31DOM nodesEvery item in the DOM hierarchy is said to be a node (A generic object)
    Most items are special types of node,
    - Indicated by the nodeType property in the node
    The key things to remember are
    - the entire document is represent by a Document node
    - every HTML element is represented by an Element node
    - the text inside an element is represented by a Text node(which does not have a corresponding HTML element)
    - every HTML attribute is represented by an Attribute node
  32. 32DOM node typesNode is the general type:
    - DOM view: HTML document is a tree of Node objects
    Nodes have properties and methods
    - Properties: nodeType, firstChild, lastChild, parentNode, nextSibling, textContent...
    - Methods: appendChild(), hasChildNodes(), hasAttributes(), removeChild()....
  33. 33DOM: node typesELEMENT_NODE
    ATTRIBUTE_NODE
    TEXT_NODE
    CDATA_SECTION_NODE
    ENTITY_REFERENCE_NODE
    ENTITY_NODE
    PROCESSING_INSTRUCTION_NODE
    COMMENT_NODE
    DOCUMENT_NODE
    DOCUMENT_TYPE_NODE
    DOCUMENT_FRAGMENT_NODE
    NOTATION_NODE
  34. 34Document NodesThe document node represents the entire HTML document. The methods and properties allow us to access and modify element in the document.
    Apart from the methods and properties inherited from the node, document has other methods and properties such as
    Properties:
    - documentElement, title, URL, etc
    Methods: write(), getElementById(), getElementByTagName(), createElement(), createTextNode(), createComment()
  35. 35Element NodesElement nodes represent an HTML element. They can have child nodes of type element nodes, text nodes and comment nodes
    Properties:
    - tagName, id, attribute etc
    Methods:
    getAttribute(), setAttribute(),...
    "Objects that implement the Element interface have all properties
    and methods of the Node interface as well as the properties and methods of elements"
  36. 36Attr nodesThe attr node represents an HTML attribute
    The attribute property of element returns a NamedNodeMap object which consists of the attribute objects of the element
    Nodes in the NamedNodeMap can be accessed by name or by index
    Properties:
    - Name, value etc
    Methods:
    - nodemap.setNamedItem(). nodemap.item(), etc
  37. 37Text nodesThe text nodes represent the textual content of an element
    Properties:
    - isElementContentWhitespace
    Methods:
    -appendData(), deleteData(), insertData(), etc..
  38. 38DOM: the data structureSo for any given node we can programmatically identify all of its children(including text nodes) and all of its attributes
    In fact we could traverse the entire DOM tree of a document Each node has a property nodeType
  39. 39Navigating the DOM: node to nodeWe need to begin from some point
    - Document.documentElement always returns the HTML element of the tree
    We can use the following properties to move around in the DOM
    - parentNode
    -childNodes[nodeNumber]
    -firstChild
    -lastChild
    -nextSibling
    previousSibling
    Collect all the text in the tags of the document and display it in a popup box
    Find out the source of the image in the tag
  40. 40Navigating the DOM: direct accessdocument.getElementById("some_id");
    document.getElementsByTagName("div");
  41. 41DOM manipulationThere are two ways we can change the content of a page element
    -the textContent property
    document.getElementById("id).textContent="some text"
    -the innerHTML property
    document.getElementById("id).innerHTML = " some text
    "
  42. 42textContent and the DOMtextContent is a property in the node object
    Therefore every node in the DOM tree has this property
    - This property however makes sense only in the case of HTML elements that have text
    - Using this property on other elements will return unexpected results
    textContent property sets or gets the text in the child text node of the element
    document.getElementById("some_node").textContent = "New Text";
  43. 43innerHTML and the DOMthe innerHTML property of a node allows us to set the content to an arbitrary string of HTML markup

Informationen

Beschreibung
Karteikarten am COMP233, erstellt von Cherese Eriepa am 29/10/2015.
Erstellt von
Cherese Eriepa
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck