Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 11 pages
Exam (elaborations)

PHP Exam1 Questions and Correct Answers

Document preview thumbnail
Preview 2 out of 11 pages

PHP Exam1 Questions and Correct Answers

Content preview

PHP Exam1 Questions and Correct
Answers



Explain what previd is (line 16), how it gets created and what it contains. - $id=$_GET['previd'] - Answer-
PrevId is a URL parameter



It was attached to a URL as part of an anchor tag on a previous page that we don't have



It is used to pass the ID number of the product that is selected by the user on the produced page using
the GET method



When the user clicks on the anchor, the ID number is captured by this parameter and passed to this
current page (nicepage.php)



hometeq.com/prevId=123



Describe what happens to previd and $id if the user the selects the 'Cookie Jar' in the pro table
presented on the "Sample Data and PHP Code" document. - Answer-When the user clicks on the cookie
jar *anchor*, the value of the id for this product 6211 gets appended to the url as previd



This makes use of the GET method to pass a value (6211) by URL

When using this method a *superglobal variable*

, $_GET('prevId') gets created to capture the value



The value (6211) then gets assigned to a local variable called $id for greater convenience.



This local variable is then used as part of a query in line 18 to retrieve all the details of this specific
product (ie. the cookie jar)



Explain what $SQL is (line 18), how it gets created and what value it contains.

$SQL = "select * from pro where prId=".$id; - Answer-$SQL is a local variable of type string



It gets assigned a SQL query



This SQL query retrieves all the details from the pro table for which the id of the product matches the
value of the id selected by the user



This value is currently stored in the local variable $id and was passed from the previous page using the
GET method



This SQL query is executed on line 19 using the mysqli_query function



Explain what $runSQL is (line 19), how it gets created and what value it contains.

$runSQL = mysqli_query($conn,$SQL) or die(mysqli_error($conn)); - Answer-The $runsql is a variable of
type boolean



It gets assigned the outcome of the execution of the SQL query or an error

Document information

Uploaded on
January 17, 2025
Number of pages
11
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$14.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Zanaya
4.5
(12)
Sold
77
Followers
29
Items
10176
Last sold
3 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions