SELECT 
  companyName, 
  PriceAvg 
FROM 
  (
    SELECT 
      `companyId`, 
      AVG(`price`) AS PriceAvg 
    FROM 
      phone 
    GROUP BY 
      `companyId`
  ) AS reporttable 
  INNER JOIN company ON reporttable.companyId = company.companyId
  ORDER BY PriceAvg DESC LIMIT 1;SELECT 
	users.name, 
	COUNT(books.id) books_count, 
	COUNT(DISTINCT books.author) authors_count
FROM users
JOIN user_books ON users.id = user_books.user_id
JOIN books ON books.id = user_books.book_id
WHERE users.birth_year BETWEEN 2004 AND 2014
GROUP BY users.name
HAVING books_count = 2 AND authors_count = 1;ALTER TABLE jshopping_orders ADD COLUMN IF NOT EXISTS bonus varchar(24) NOT NULL DEFAULT '';select sum(budget) from (
	select distinct project, budget from projects
) p;<?php
$raw = '{
	"lastUpdateId":4409859389,
	"bids":[
		["2.13000000","6472.90000000"],
		["2.12900000","50106.20000000"],
		["2.12800000","63127.60000000"],
		["2.12700000","31495.40000000"],
		["2.12600000","41493.30000000"]
	],
	"asks":[
		["2.13100000","24755.90000000"],
		["2.13200000","86227.50000000"],
		["2.13300000","58302.20000000"],
		["2.13400000","61187.90000000"],
		["2.13500000","39494.50000000"]
	]
}';
$data = json_decode($raw, true);
$bids = array_column($data["bids"], 1);
$asks = array_column($data["asks"], 1);
echo "Max bid: " . max($bids) ,PHP_EOL;
echo "Max ask: " . max($asks) ,PHP_EOL;$str = '[id618892552|Victoria Tran]';
list($id, $name) = explode('|', trim($str, ']['));$json = '
{
    "program_id": "CC1234",
    "offerings": [{
        "offering_id": "RP445555",
        "location_id": "B2222"
    }],
    "member_id": "10000-01",
    "registration_type": "online",
    "dry_run": false
}';
$php_array = json_decode($json, true);
var_export($php_array);array (
  'program_id' => 'CC1234',
  'offerings' => 
  array (
    0 => 
    array (
      'offering_id' => 'RP445555',
      'location_id' => 'B2222',
    ),
  ),
  'member_id' => '10000-01',
  'registration_type' => 'online',
  'dry_run' => false,
)<?php
$a=17;
if ($a < 0 ) {
	if ($a % 2 === 1) {
		echo "$a is negative odd";
	} else {
		echo "$a is negative even";
	}	
} else {
	if ($a % 2 === 1) {
		echo "$a is positive odd";
	} else {
		echo "$a is positive even";
	}
}function positive_or_negative($a) {
	return ($a < 0 ) ? 'negative' : 'positive';
}
function odd_or_even($a) {
	return ($a % 2 === 1 ) ? 'odd' : 'even';
}
echo "$a is " 
		. positive_or_negative($a)
		. " "
		. odd_or_even($a);$con = mysqli_connect("localhost", "root", "", "dbname");
$result = mysqli_query($con, 'SELECT * FROM nomen');
$fp = fopen('file.csv', 'w');
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
    fputcsv($fp, $row);  
}
fclose($fp);<?php
require "index.html";
header("Content-type: text/plain; charset=utf-8");
if (
	$_SERVER['REQUEST_METHOD'] == "POST" &&
	isset($_POST["name"]) && 
	isset($_POST["message"])
) {
	$to = "damirgaliev587@gmail.com";
	$tema = "Форма обратной связи на PHP";
	$message = "Ваше имя: " . $_POST["name"] . "<br>";
	$message .= "E-mail: " . $_POST["email"] . "<br>";
	$message .= "Номер телефона: " . $_POST["phone"] . "<br>";
	$message .= "Сообщение: " . $_POST["message"] . "<br>";
	$headers = "MIME-Version: 1.0" . "\r\n";
	$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
	mail($to, $tema, $message, $headers);
}
?>foreach( $arr as $key=>$value ) {
	if ($value[1]) {
		printf("%s %s\n", $value[0], $value[2]);  
	}
}// Перебор массива
foreach( $arr as $key=>$value ) {
	if ($$key) {
		printf("%s %s\n", $value[0], ucfirst($key));  
	}
}