Results: 1024
Meeting 1
PHP Variables https://learning.applications.ge/note/public/3278 https://www.sololearn.com/learning/1059/1797/3456/1 https://www.w3schools.com/php/php_variables.asp https://www.javatpoint.com/php-variables https://www.tutorialrepublic.com/php-tutorial/php-variables.php Arithmetic Operators https://learning.applications.ge/note/public/3293 https://www.sololearn.com/learning/1059/1803/3469/1 https://www.w3schools.com/php/php_operators.asp Assignment Operators https://learning.applications.ge/note/public/3294 https://www.sololearn.com/learning/1059/1804/3472/1 https://www.w3schools.com/php/php_operators.asp Comparison Operators https://learning.applications.ge/note/public/3295 https://www.sololearn.com/learning/1059/1805/3503/1 https://www.w3schools.com/php/php_operators.asp Rules to create PHP variable https://learning.applications.ge/note/public/3277 https://www.roseindia.net/tutorial/php/phpbeginners/PHPvariable.html Case Sensitivity https://learning.applications.ge/note/public/3283 https://tutorialsclass.com/faq/is-php-a-case-sensitive-language/ PHP Comments https://learning.applications.ge/note/public/3279 https://www.sololearn.com/learning/1059/1795/3453/1 https://www.w3schools.com/php/php_comments.asp https://www.javatpoint.com/php-comments https://www.phptutorial.net/php-tutorial/php-comments/ echo / print https://learning.applications.ge/note/public/3280 https://www.sololearn.com/learning/1059/1794/3450/1 https://www.w3schools.com/php/php_echo_print.asp https://www.javatpoint.com/php-echo https://www.javatpoint.com/php-print https://www.tutorialrepublic.com/php-tutorial/php-echo-and-print-statements.php Differences between echo and print https://learning.applications.ge/note/public/3281 https://www.javatpoint.com/php-echo-and-print-statements Variable types https://learning.applications.ge/note/public/3282 https://www.sololearn.com/learning/1059/1796/3501/1 https://www.w3schools.com/php/php_datatypes.asp https://www.tutorialspoint.com/php/php_variable_types.htm https://www.javatpoint.com/php-data-types https://www.phptutorial.net/php-tutorial/php-data-types/ https://www.tutorialrepublic.com/php-tutorial/php-data-types.php Array types https://learning.applications.ge/note/public/3286 https://www.sololearn.com/learning/1059/1807/3476/1 https://www.sololearn.com/learning/1059/1808/3504/1 https://www.sololearn.com/learning/1059/1809/3505/1 https://www.w3schools.com/php/php_arrays.asp https://www.tutorialspoint.com/php/php_arrays.htm https://www.phptutorial.net/php-tutorial/php-array/ https://www.phptutorial.net/php-tutorial/php-associative-arrays/ https://www.phptutorial.net/php-tutorial/php-multidimensional-array/ https://www.tutorialrepublic.com/php-tutorial/php-arrays.php String functions https://learning.applications.ge/note/public/3284 https://www.w3schools.com/php/php_string.asp https://www.tutorialrepublic.com/php-tutorial/php-strings.php Math functions https://learning.applications.ge/note/public/3285 https://www.w3schools.com/php/php_math.asp If statement https://learning.applications.ge/note/public/3287 https://www.w3schools.com/php/php_if_else.asp https://www.tutorialspoint.com/php/php_decision_making.htm https://www.phptutorial.net/php-tutorial/php-if/ https://www.tutorialrepublic.com/php-tutorial/php-if-else-statements.php If-else statement https://learning.applications.ge/note/public/3288 https://www.sololearn.com/learning/1059/1823/3515/1 https://www.phptutorial.net/php-tutorial/php-if-else/ Else-if statement https://learning.applications.ge/note/public/3289 https://www.sololearn.com/learning/1059/1824/3517/1 https://www.phptutorial.net/php-tutorial/php-if-elseif/ Logical Operators https://learning.applications.ge/note/public/3305 https://www.sololearn.com/learning/1059/1806/3474/1 https://www.w3schools.com/php/php_operators.asp User defined functions https://learning.applications.ge/note/public/3290 https://www.sololearn.com/learning/1059/1834/3540/1 https://www.sololearn.com/learning/1059/1835/3542/1 https://www.w3schools.com/php/php_functions.asp https://www.tutorialspoint.com/php/php_functions.htm https://www.phptutorial.net/php-tutorial/php-function/ https://www.tutorialrepublic.com/php-tutorial/php-functions.php Loops https://learning.applications.ge/note/public/3291 https://www.sololearn.com/learning/1059/1826/3521/1 https://www.w3schools.com/php/php_looping.asp https://www.tutorialspoint.com/php/php_loop_types.htm https://www.phptutorial.net/php-tutorial/php-for-loop/ https://www.tutorialrepublic.com/php-tutorial/php-loops.php The break statement https://learning.applications.ge/note/public/3316 https://www.w3schools.com/php/php_looping_break.asp The continue statement https://learning.applications.ge/note/public/3317 https://www.sololearn.com/learning/1059/1831/3531/1 https://www.w3schools.com/php/php_looping_break.asp Main resources to learn PHP basics: https://www.php.net/ (official doc) https://www.sololearn.com/learning/1059 https://www.w3schools.com/php/ https://www.phptutorial.net/ https://www.tutorialrepublic.com/php-tutorial/ https://www.tutorialspoint.com/php/ https://www.javatpoint.com/php-tutorial PHP online editors: https://onlinephp.io/ https://www.writephponline.com/ https://www.mycompiler.io/new/php
PHP else-if statement CODE
The code will output "Have a nice weekend!" if the current day is Friday, and "Have a nice Sunday!" if the current day is Sunday, otherwise it will output "Have a nice day!"
$d = date("D");
if($d == "Fri"){
    echo "Have a nice weekend!";
} elseif($d == "Sun"){
    echo "Have a nice Sunday!";
} else{
    echo "Have a nice day!";
}
echo "\n";
Outputs
Have a good morning!
if the current time is less than 10, and
Have a good day!
if the current time is less than 20. Otherwise it will output
Have a good night!
$t = date("H");
if ($t < "10") {
	echo "Have a good morning!";
} elseif ($t < "20") {
	echo "Have a good day!";
} else {
	echo "Have a good night!";
}
Prints
Adult
If
$age
is more than
18
, and
Teenager
if the variable is less than 12. Otherwise it prints
Child
$age = 20;
if ($age > 18) {
    echo 'Adult';
} else if ($age > 12) {
    echo 'Teenager';
} else {
    echo 'Child';
}
PHP If statement CODE
If the current day is Friday the code will output "Have a nice weekend!" PHP datetime format: https://www.php.net/manual/en/datetime.format.php
$d = date("D");
if ($d == "Fri"){
    echo "Have a nice weekend!";
}
If the current hour is less than 20, the code will output "Have a good day!"
$t = date("H");
if ($t < "20") {
  echo "Have a good day!";
}
If
$age
is more than
18
, prints
Adult
$age = 20;
if ($age > 18) {
	echo 'Adult';	
}
Array types CODE
Indexed array
$colors = ["Red", "Green", "Blue"];
$colors[] = "Yellow";
Associative arrays
$student = [
	"name"=>"George", 
	"weight"=>77, 
	"height"=>1.8, 
	"male"=>true
];
$student["male"] = true;
echo 'George is ' . $student['weight'] . 'kg'."\n";
Multidimensional arrays
$students = [
	"George"=> [
		"name"=>"George", 
		"weight"=>77, 
		"height"=>1.8, 
		"male"=>true
	],
	"Alex"=> [
		"name"=>"Alex", 
		"weight"=>87, 
		"height"=>2.8, 
		"male"=>true,
		"parents"=> [
			"father"=>"David",
			"mother"=>"Marta",
		]
	],
	
];
echo 'Alex weighs ' . $students['Alex']['weight'] . 'kg'."\n";
echo "Alex's father is: " . $students['Alex']['parents']['father'];
Math functions CODE
Function
min()
finds the lowest value from its arguments
echo min(10, 15, 7, 9, 17)."\n"; // 7
Function
max()
finds the highest value from its arguments
echo max(10, 15, 7, 9, 17)."\n"; // 17
Function
count()
counts all elements in the array
echo count([10, 15, 7, 9, 17])."\n";
Function
round()
rounds a floating-point number to its nearest integer
echo(round(0.75))."\n";  // returns 1
echo(round(0.5))."\n";  // returns 1
echo(round(0.49))."\n";  // returns 0
Function
floor()
rounds the floating-point number down
echo floor(3.3)."\n";// 3  
echo floor(7.84)."\n";// 7 
echo floor(-4.8)."\n";// -5  
Function
ceil()
rounds the floating-point number up
echo ceil(3.3)."\n";// 4
echo ceil(7.84)."\n";// 8
echo ceil(-4.8)."\n";// -4
Function
rand()
generates a random number
echo rand()."\n";
// Generates a random number from the range
echo rand(10, 100)."\n";
Function
sqrt()
returns the square root of a number
echo sqrt(64)."\n";  // 8
Function
pow()
raises 2 to the power of 3
echo pow(2, 3)."\n";  // 8
Function
pi()
Returns PI value
echo pi()."\n";// 3.1415926535898
Function
abs()
returns the positive (absolute) value of a number
echo abs(-12)."\n";
Function
decbin()
converts decimal number into binary
echo decbin(2)."\n";// 10 
Differences between echo and print CODE
1.
echo
can take multiple parameters
echo 'one', 'two', 'three', "\n";
2.
print
statement returns 1
$print_returns = print('some text')."\n";
echo "print_returns Value: $print_returns" . "\n";
echo
prints 1 after
print
statement is executed
echo print "123", "\n";
3.
echo
is a little bit faster than
print
set footer background after only scroll down event
Sets background image only when a user scrolls down (not to load every image at first)
document.addEventListener("scroll", setBG);
function setBG() {
    if (!bgSet) {
        var bgSet=1;
        id('table_footer').style.background='url(/images/footer.jpg?tg)';
        document.removeEventListener("scroll", setBG);
        console.log('fired');
    }
}
several ways to put space between table rows CODE
fThe First way is to use
border-spacing
property
table {
    border-collapse:separate;
    border-spacing:0 15px;
}
Another way is to put additional separator TRs
<tr class="separator" />
between rows
.separator {
    height: 10px;
}
Third way is to use
margin-bottom
property
tr { 
    display: block;
    margin-bottom: 15px;
}
<?php
if(stristr($_SERVER['HTTP_USER_AGENT'], "Mobile")){ // if mobile browser
?>
        <link rel="stylesheet" href="style-400.css" type="text/css" />
<?php
} else { // desktop browser
?>
        <link rel="stylesheet" href="style.css" type="text/css" />
<?php
}
?>
The function gets data table, passes to recursive function to get associative array back. Encodes the array to JSON and returns back to user:
public function getCategoryTreeJSON()
{
    $query = "  SELECT
                    c1.id,
                    c1.name,
                    c1.parent_id,
                    (
                        SELECT
                            COUNT(c2.id) 
                        FROM
                            categories AS c2 
                        WHERE
                            c2.parent_id = c1.id
                    )
                    AS children_count 
                FROM
                    categories AS c1";

    $categoryDetails = json_decode(json_encode(DB::select($query)), true);
    
    $array_tree = $this->getCategoryTreeArray($categoryDetails);

    return json_encode($array_tree);
}
Recursive function that returns multi level associative array. Base case: when
children_count
is equal to zero.
public function getCategoryTreeArray($items, $parent_id = 0)
{
    $branch = [];
    $array_JSON = [];  

    foreach ($items as $item) {
        if ($item['parent_id'] == $parent_id) {

            if ($item['children_count'] > 0) {
                
                $array_JSON[] = [
                    'id'=>$item['id'],
                    'title'=>$item['name'],
                    'subs'=>$this->getCategoryTreeArray($items, $item['id'])
                ];
                
            } else {
                
                $array_JSON[] = [
                    'id'=>$item['id'],
                    'title'=>$item['name']
                ];
            }
            
        }
    }
    return $array_JSON;
}
Results: 1024