Question: I'm learning SQL and I wanted to select a certain list of names and telephone numbers for a certain ID number. These names are names of customers who bought Furniture with FurnitureID. This list also should be presented in alphabetical order of the names of the customers. I'm not sure how Join works and how I could also list it in alphabetical order of the customers names. 

So a customer places an order at the store and the company then orders the furniture required from its suppliers. When the ordered furniture arrives at the store a member of staff telephones or emails the customer to inform them that it is ready for collection. Customers often order more than one type of furniture on the same order, for example a sofa and two chairs.

The tables are stored in a relational database:

* Furniture(*FurnitureID*, FurnitureName, Category, Price, SupplierName)
* CustomerOrder(*OrderID*, CustomerID, Date)
* CustomerOrderLine(*OrderID*, *FurnitureID*, Quantity)
* Customer(*CustomerID*, CustomerName, EmailAddress, TelephoneNumber)

What I've done so far is: 

```
SELECT Furniture.FurnitureID, Customer.CustomerName, Customer.TelephoneNumber) 
FROM Furniture, Customer 
WHERE FurnitureID = 10765

```

Thank you!

Answer: 
It is better to use `DOM` instead of `regex` in order to manipulate `HTML`. 
Using `DOM` you can effectively manipulate the `HTML` document, with the help of [DOMNode::appendChild](https://www.php.net/manual/en/domnode.appendchild.php) and [DOMDocument::createTextNode](https://www.php.net/manual/en/domdocument.createtextnode.php) you can insert text coming from `$variable` after the `h2` element.

We get the parent of the `h2` element (`$doc->getElementsByTagName('h2')->item(0)->parentNode`) and append a child to it, that will be placed after the `h2`. This child is a textnode created from the input `$variable` (`$doc->createTextNode($variable)`).

```
$html = '<div><div><h2>Hi</h2></div></div>';
$variable = 'Hello Stackoverflow';
$doc = new DOMDocument();
$doc->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
$newTextNode = $doc->createTextNode($variable);
$doc->getElementsByTagName('h2')->item(0)->parentNode->appendChild($newTextNode);
echo $doc->saveHTML();

```

Results in:

```
<div><div><h2>Hi</h2>Hello Stackoverflow</div></div>

```
You can't add variable in single quotes, your second parameter should be in double quotes "$variable" , not '$variable'

You can find very good ref for Single vs double quotes here:
[What is the difference between single-quoted and double-quoted strings in PHP?](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php)