Tag

PHP

Browsing

Sorting array value without using built in php like sort() etc Bubble sort in php <?php $array =array(‘2′,’4′,’8′,’5′,’1′,’7′,’6′,’9′,’10’,’3′); echo ‘Unsorted array’; print_r($array); for($i = 0; $i<count($array); $i++){ for($j = 0; $j <count($array)-1; $j++){ if($array[$j] > $array[$j+1]){ $temp = $array[$j+1]; $array[$j+1] = $array[$j]; $array[$j] = $temp; } } } echo ‘Sorted array’; print_r($array); ?> Reverse Order Sorting <?php $array = array(‘2′,’4′,’8′,’5′,’1′,’7′,’6′,’9′,’10’,’3′); echo ‘Unsorted array’; print_r($array); for($i = 0; $i<count($array); $i++){ for($j = 0; $j <count($array)-1; $j++){…

Step 1: Create Database Table CREATE TABLE `info` ( `id` int(11) NOT NULL, `name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Step 2: Create index.php File <html> <head> <title>jQuery Add & Remove Dynamically Input Fields in PHP</title> </head> <body> <h1>jQuery Add & Remove Dynamically Input Fields in PHP</h1> <form name=”add_me” id=”add_me”> <table id=”dynamic”> <input type=”text” name=”name[]” placeholder=”Enter Your Name” /> <button type=”button” name=”add” id=”add_input”>Add</button> </table> <input type=”button” name=”submit” id=”submit” value=”Submit” /> </form> <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.min.js”></script> <script>…

<?php $html = file_get_contents(‘https://www.practo.com/search?results_type=doctor’); //get the html returned from the following url $pokemon_doc = new DOMDocument(); libxml_use_internal_errors(TRUE); //disable libxml errors if(!empty($html)){ //if any html is actually returned $pokemon_doc->loadHTML($html); libxml_clear_errors(); //remove errors for yucky html $pokemon_xpath = new DOMXPath($pokemon_doc); //get all the h2’s with an id $pokemon_row = $pokemon_xpath->query(‘//h2[@class]’); if($pokemon_row->length > 0){ foreach($pokemon_row as $row){ echo $row->nodeValue . “<br/>”; } } } ?> Read More: https://gist.github.com/anchetaWern/6150297

https://youtu.be/4p4kI60POYs <?php //index.php $error = ”; $name = ”; $email = ”; $subject = ”; $mobile = ”; $message = ”; function clean_text($string) { $string = trim($string); $string = stripslashes($string); $string = htmlspecialchars($string); return $string; } if(isset($_POST[”submit”])) { if(empty($_POST[”name”])) { $error .= ‘<p><label class=”text-danger”>Please Enter your Name</label></p>’; } else { $name = clean_text($_POST[”name”]); if(!preg_match(“/^[a-zA-Z ]*$/”,$name)) { $error .= ‘<p><label class=”text-danger”>Only letters and white space allowed</label></p>’; } } if(empty($_POST[”email”])) { $error .= ‘<p><label class=”text-danger”>Please Enter your…

https://youtu.be/Cw8mCIK2oIY Create index.php file and put code inside of index.php file In this tutorial, we will learn how to data store inside of CSV file using PHP. CSV is a comma-separated value file in which it stores tabular data in plain text format. It stores one record in one line and for the second record, it will store in the second line. <?php //index.php $error = ”; $name = ”; $email = ”; $subject =…

There are many differences between PHP 5 and 7. Some of the main points are: Performance: PHP 7: Performance speed is double. Average requests per second are 44 when it is 22 in php5. PHP 5: Performance is low compared to php7. Return Type: In PHP 5, the programmer is not allowed to define the type of return value of a function which is the major drawback. But in PHP 7, this limitation is overcome…

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf sudo a2enconf phpmyadmin sudo service apache2 reload sudo apt update sudo apt install phpmyadmin php-mbstring php-gettext sudo phpenmod mbstring sudo systemctl restart apache2 sudo mysql -u root -p; CREATE USER ‘siddharth’@’localhost’ IDENTIFIED BY ‘admin1818’; GRANT ALL PRIVILEGES ON *.* TO ‘siddharth’@’localhost’ WITH GRANT OPTION; exit

<form action=”” class=”contact_form” id=”comment”> <center> <div id=”result”> </div> </center> <div class=”form-group”> <label for=”name”>Name* </label> <input type=”name” class=”form-control” name=”name” placeholder=”Type Here”> </div> <div class=”form-group”> <label for=”organization”>Organization name </label> <input type=”text” class=”form-control” name=”organization_name” placeholder=”xyz”> </div> <div class=”form-group”> <label for=”email”>Email* </label> <input type=”email” class=”form-control” name=”email” placeholder=”[email protected]”> </div> <div class=”form-group”> <label for=”sel1″>Service you provide </label> <select class=”form-control” name=”service_provider”> <option>Sell </option> <option>2 </option> <option>3 </option> <option>4 </option> </select> </div> <div class=”checkbox”> <label> <input type=”checkbox”> <span class=”label_span”>I accept the terms and…

Faster PHP Cloud Hosting