ADVANCED HIGHER COMPUTING(SQA) QUESTIONS
& ANSWERS
Media Query - Answer -A ________ consists of a mediatype and contain one or more
expressions, which resolve to either True or False.
@media mediatype and (expressions){
CSS-Code;
}
mediatype can be: Print(printers) or Screen(phones etc).
The expression could be max-width:?px
A _________ stylesheet would look like:
<link rel = "stylesheet" media="mediatype and (expressions)" href ="style.css">
<form> element - Answer -The HTML ______ element defines a form that is used to
collect user input.
<input> element - Answer -The ______ element can be displayed in several ways,
depending on the type attribute, e.g. type = "text".
type attribute - Answer -The ____ attribute refers to the attribute type(e.g. "text"). If the
____ attribute is omitted, the input field gets the default ____:"text"
name attribute - Answer -The ____ attribute specifies the value of an <input> element.
The ____ attribute is used to reference elements in JavaScript, or to reference form
data after it is submitted.
Only forms elements with a ____ attribute will have their values passed when submitting
a form.
_____ should be meaningful, just like variables in programming.
value attribute - Answer -The ____ attribute specifies the ____ of an <input> element. It
is used differently for different input types:
"button/reset/submit" - It defines the text for the button.
"text/password/hidden" - it defines the default _____ in the input field.
"checkbox/radio/image" - it defines the ____ associated with the input(this is also the
value that is sent on submit)
<select> element - Answer -The _______ element defines a drop-down list.
,e.g.
<select name = "cars"
<option value = "volvo">Volvo</option>
<option value = "saab">Saab</option>
</select>
<textarea> element - Answer -The ________ element defines a mulit-line input field(a
text area)
e.g.
<textarea name = "message" rows = "10" cols = "30">The cat was playing in the
garden.</textarea>
action attribute - Answer -The _____ attribute specifies where to send the form data
when it is submitted.
e.g. <form action="/phpProcessing.php" method = "GET">
method attribute - Answer -The _____ attribute specifies how to send form data(GET or
POST).
The form data can be sent as URL variables(GET) or HTTP post transcription(POST).
<table> element - Answer -The ______ element defines a HTML table.
-Each row is defined with the <tr> tag.
-A table header is defined with the <th> tag.
-A table data/cell is defined as the <td> tag.
e.g.
<table>
<tr>
<th>FirstName</th>
</tr>
<tr>
<td>Jill</td>
</tr>
</table>
$_get() / $_post() - Answer -...
$variable = $_POST["formData"]
OR
$variable = $_GET["formData"]
...
, mysqli_connect() - Answer -used to initiate a new connection with the MySQL server:
$con = mysqli_connect()("localhost","my_user","password","my_db");
mysqli_connect_errno() - Answer -Returns the error code from the last connection
error.
e.g.
//Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect: " .
mysqli_connect_error();
}
mysqli_close() - Answer -closes a database connection.
e.g.
mysqli_close($con);
die() - Answer -// ʙʟᴀɴᴋ ᴜʀʟ ᴏғ sɪᴛᴇ
// sᴏ ᴛʜᴀᴛ ᴅɪᴇ() ɪs ᴇxᴇᴄᴜᴛᴇᴅ
$ s ɪ ᴛ ᴇ = "";
// ᴏᴘᴇɴ ᴜʀʟ ᴇʟsᴇ ᴅɪᴇ (ᴇxɪᴛ)
ғ ᴏ ᴘ ᴇ ɴ($ s ɪ ᴛ ᴇ, "ʀ")
ᴏ ʀ ᴅ ɪ ᴇ ("ᴜɴᴀʙʟᴇ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ᴛᴏ ɢɪᴠᴇɴ sɪᴛᴇ.");
mysqli_query() - Answer -//$con refers to db connection
...
mysqli_query($con, "SELECT * FROM Persons");
...
This can also be done as:
...
$sql = "SELECT firstname FROM MyGuests";
$result = $conn -> query($sql);
...
echo() - Answer -The echo statement can be used with or without parentheses and can
contain HTML code.
...
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
...
& ANSWERS
Media Query - Answer -A ________ consists of a mediatype and contain one or more
expressions, which resolve to either True or False.
@media mediatype and (expressions){
CSS-Code;
}
mediatype can be: Print(printers) or Screen(phones etc).
The expression could be max-width:?px
A _________ stylesheet would look like:
<link rel = "stylesheet" media="mediatype and (expressions)" href ="style.css">
<form> element - Answer -The HTML ______ element defines a form that is used to
collect user input.
<input> element - Answer -The ______ element can be displayed in several ways,
depending on the type attribute, e.g. type = "text".
type attribute - Answer -The ____ attribute refers to the attribute type(e.g. "text"). If the
____ attribute is omitted, the input field gets the default ____:"text"
name attribute - Answer -The ____ attribute specifies the value of an <input> element.
The ____ attribute is used to reference elements in JavaScript, or to reference form
data after it is submitted.
Only forms elements with a ____ attribute will have their values passed when submitting
a form.
_____ should be meaningful, just like variables in programming.
value attribute - Answer -The ____ attribute specifies the ____ of an <input> element. It
is used differently for different input types:
"button/reset/submit" - It defines the text for the button.
"text/password/hidden" - it defines the default _____ in the input field.
"checkbox/radio/image" - it defines the ____ associated with the input(this is also the
value that is sent on submit)
<select> element - Answer -The _______ element defines a drop-down list.
,e.g.
<select name = "cars"
<option value = "volvo">Volvo</option>
<option value = "saab">Saab</option>
</select>
<textarea> element - Answer -The ________ element defines a mulit-line input field(a
text area)
e.g.
<textarea name = "message" rows = "10" cols = "30">The cat was playing in the
garden.</textarea>
action attribute - Answer -The _____ attribute specifies where to send the form data
when it is submitted.
e.g. <form action="/phpProcessing.php" method = "GET">
method attribute - Answer -The _____ attribute specifies how to send form data(GET or
POST).
The form data can be sent as URL variables(GET) or HTTP post transcription(POST).
<table> element - Answer -The ______ element defines a HTML table.
-Each row is defined with the <tr> tag.
-A table header is defined with the <th> tag.
-A table data/cell is defined as the <td> tag.
e.g.
<table>
<tr>
<th>FirstName</th>
</tr>
<tr>
<td>Jill</td>
</tr>
</table>
$_get() / $_post() - Answer -...
$variable = $_POST["formData"]
OR
$variable = $_GET["formData"]
...
, mysqli_connect() - Answer -used to initiate a new connection with the MySQL server:
$con = mysqli_connect()("localhost","my_user","password","my_db");
mysqli_connect_errno() - Answer -Returns the error code from the last connection
error.
e.g.
//Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect: " .
mysqli_connect_error();
}
mysqli_close() - Answer -closes a database connection.
e.g.
mysqli_close($con);
die() - Answer -// ʙʟᴀɴᴋ ᴜʀʟ ᴏғ sɪᴛᴇ
// sᴏ ᴛʜᴀᴛ ᴅɪᴇ() ɪs ᴇxᴇᴄᴜᴛᴇᴅ
$ s ɪ ᴛ ᴇ = "";
// ᴏᴘᴇɴ ᴜʀʟ ᴇʟsᴇ ᴅɪᴇ (ᴇxɪᴛ)
ғ ᴏ ᴘ ᴇ ɴ($ s ɪ ᴛ ᴇ, "ʀ")
ᴏ ʀ ᴅ ɪ ᴇ ("ᴜɴᴀʙʟᴇ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ᴛᴏ ɢɪᴠᴇɴ sɪᴛᴇ.");
mysqli_query() - Answer -//$con refers to db connection
...
mysqli_query($con, "SELECT * FROM Persons");
...
This can also be done as:
...
$sql = "SELECT firstname FROM MyGuests";
$result = $conn -> query($sql);
...
echo() - Answer -The echo statement can be used with or without parentheses and can
contain HTML code.
...
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
...