One place for hosting & domains

      October 2019

      How to Get Started as a WordPress Contributor


      And WordPress — the behemoth that powers 30% of the internet — is the ultimate open-source project. That means it’s developed and maintained by a dedicated community of contributors — awesome people like you and me — rather than a for-profit company.

      Even better? Becoming one of those stalwart WordPress contributors and shaping the future of the platform is easier than you might imagine. Plus, there are many excellent avenues for contributing. Along with the obvious coding and development roles, you can get involved in design, translation, community outreach, and much more.

      So let’s first talk about what contributing to WordPress actually means (no, you’re not going to be pressing words, Amelia Bedelia) and why you should do it. Then I’ll walk you through the step-by-step process of finding your niche and making the right connections.

      Why You Should Consider Contributing to WordPress

      wordpress-homepage.PNG
      WordPress’ community is what made it the flexible, powerful platform it is today.

      WordPress.org is a totally free and open-source platform. This means that instead of being run by a large company, WordPress is developed and maintained by a dedicated community of users.


      “Wait, rewind! What about WordPress.com?”

      Great question! WordPress.org offers free software that anybody can use to create a self-hosted website. WordPress.com uses the same platform but is run by a for-profit company. If you really want to get into the nitty-gritty about WordPress, both the .com and .org sites, check out our WordPress Differences Beginner’s Guide.

      In this post, we’re just talking about WordPress.org — the open-source, free-to-use software.

      OK, back to it.


      WordPress relies on this community of users to keep it updated, add new features and functionality, provide testing and support, and much more.

      Of course, you don’t need to know anything about the larger world of WordPress to use the platform for your own websites — you can literally set up a WordPress website in just a few minutes.

      However, it may be worth your while to get involved in the platform’s development, and here’s why:

      • You get the chance to give back to the community that’s provided you with an invaluable resource.
      • Working as a contributor helps you learn more about WordPress, as well as other areas related to web development.
      • It’s a perfect way to exercise your existing skills or develop new abilities.
      • You’ll gain valuable experience you can add to your resume or use to attract clients.
      • Immersing yourself in the WordPress community enables you to make connections and build professional and personal relationships with other contributors.

      Altogether, these reasons build a compelling case for giving the role of WordPress contributor a try. What’s more, you have the flexibility to put as much or as little time into the endeavor as you’d like, and there are plenty of different ways to get involved.

      WordPress + DreamHost

      Our automatic updates and strong security defenses take server management off your hands so you can focus on creating a great website.

      How to Get Started as a WordPress Contributor

      Just like walking into a real-life party, you’ve got to find the right place for you in the WordPress crowd — whether it’s on the development dance floor or in the community outreach corner. Regardless of your particular niche and skill set, you can follow these three steps to get off on the right foot as a WordPress contributor.

      Step 1: Research WordPress and Its Community

      wp-apprentice-course.PNG
      Structured courses found on sites like WP Apprentice are a perfect way to learn about WordPress.

      Whether you’re a relative noob or you’ve been using WordPress for years, learning more about the platform and its community is a smart first step. For one, you’ll need more in-depth knowledge about WordPress as a contributor than you ever did as a user. Plus, spending some time immersed in WordPress can help you figure out where you’ll fit into the picture.

      Start out by reading up on the history and development of WordPress. This will provide you with a solid grounding in the platform’s mission and goals and will give you some idea of how far it’s come over time. WordPress has followed a long road from its beginning as simple blogging software to its current iteration as a multifaceted Content Management System (CMS), and there have been plenty of twists and turns along the way.

      Once you have a better sense of how the platform came to be and the ways it’s changed since its inception, you can begin to learn more about its present-day form, focusing on whatever areas catch your interest. This step can take as much or as little time as you’d like, depending on how much you already know.

      There are plenty of ways to learn about WordPress, but some excellent places to start include:

      • Structured Online Courses — You can find a ton of options out there, from free half-hour tutorials to longer, more pricey options.
      • Dedicated YouTube Channels — There’s lots of free, quality information available on YouTube, mainly through channels such as WPBeginner and WPCrafter.
      • News Sources — Of course, you’ll want to keep your eye on the official WordPress.org news page. However, there are also other sites devoted to the latest WordPress happenings, such as WP Tavern and Post Status.
      • Forums — The web is packed with forums devoted to WordPress in general and to specific themes, plugins, and more. You can find them on WordPress.org itself, on developer websites, and through Google searches.
      • Blogs — There are blogs for WordPress beginners, experts, developers, and just about every niche you can think of. Reading posts on sites like Torque and our own blog is a simple, free way to learn much of what you’ll need to know.

      Throughout the course of your research, take note of your favorite resources. You’ll want to keep visiting them over time, to stay up to date and continue your WordPress education. When you feel like you have a solid understanding of WordPress and know what aspects interest you most, it’s probably time to move on to the next step.

      Step 2: Decide on a Field of Contribution

      make-wordpress-homepage.PNG
      Make WordPress is home to many teams of contributors and volunteers.

      If you’re imagining that all WordPress contributors are developers or programmers, it’s time to stop with the stereotypes.

      Just kidding.

      Many people make this assumption! Of course, a lot of people in the WordPress community are developers and programmers. However, there are a lot more options available when it comes to getting involved with the platform.

      A project as big and complex as WordPress needs many kinds of people to keep it running. This is fortunate because it means you’re likely to find an area of contribution that’s perfectly suited to your personal skill set and goals. Whether you’re interested in design, writing, or working with people, you can easily find a role to match your desires (or more than one).

      The research stage should have given you a few ideas for where you might fit into the WordPress community. There are a lot of options available.

      Core Development and Beta Testing

      This is the area that probably comes to mind first when you think about WordPress contributors. Plenty of coders are required to work on the project — they’re responsible for adding new features, improving existing functionality, creating updates and patches, beta testing, and fixing bugs and other issues. Some developers stick to one or two areas of expertise, while others try their hand at just about everything.

      If you’re at all interested in coding and development, you should get involved. What’s more, you don’t need to be an expert or have a lot of experience. WordPress is a beginner-friendly project and has some simple ways to get you started even if you’re a relative novice. You can get your feet wet with the WordPress Beta Tester plugin, then work your way up. Plus, experienced developers are always around to help you out and answer questions.

      The best place to start if you’re interested in core development and beta testing is by reading through the Core Contributor Handbook. This resource will tell you just about everything you need to know about the project’s organization, workflows, best practices, and more. Then, you can get started with some tasks earmarked for beginning contributors, such as handling basic bugs and testing patches.

      Design and User Interface

      wordpress-dashboard.PNG
      WordPress’ user interface is the result of years of work by designers and developers.

      If you’re more of a designer than a developer, you may be interested in helping to improve the platform’s design and user interface (UI). These are key elements that impact the experience of every person who uses the platform. A solid UI streamlines the workflow for experienced users and makes their lives a little easier. And it definitely plays a major role in whether or not newcomers stick around.

      WordPress’ design and UI are constantly evolving as developers and users find better ways to organize information and handle common tasks. Just as with core development, the team behind this niche is open to anyone who wants to help out. Some design experience will certainly enable you to get up and running more quickly, but you don’t need to be an expert.

      There are a number of ways to start contributing to WordPress’ UI and design. You can deal with design-related tickets, work on mockups, or help out with whatever the team’s current primary focuses happen to be. Before jumping into any of these projects, check out the Design Handbook and then follow the recommended first steps for getting involved.

      Plugin and Theme Development

      This area of contribution is a little different from the rest. Creating themes and plugins isn’t exactly part of the main WordPress project even though it’s a crucial aspect of the platform’s development. The wide availability of free and low-cost themes and plugins is a big part of what makes WordPress so popular, and what keeps it relevant year after year. Adding to that collection helps expand the CMSs capabilities, so this is a vital function.

      You’ll need some experience with coding and development if you want to jump straight into building plugins and themes. If you are a complete beginner, though, you’ll simply need to spend some time beefing up your skills. Put in the effort to learn about how themes and plugins work, then start out by creating something small and simple. Let other people test the results and use their feedback to improve.

      For plugin and theme development, you may want to start with a dedicated course. There are free options as well as premium tutorials from services like Udemy. You’ll also find relevant information about building themes and creating plugins in the WordPress Codex. If you run into any trouble along the way, have questions, or want to find a team to collaborate with, check out the official WordPress.org forums. Chances are, you’ll find lots of developers there who are willing to help you out.

      Documentation

      wordpress-codex.PNG
      The WordPress Codex is a handy resource that needs to be kept up-to-date at all times.

      Perhaps, like myself, you’re more of a writer than a developer — where do the word people fit in the WordPress community? On the documentation team. Boom.

      WordPress is a complex CMS with a lot of moving parts — plenty of resources are required to teach people the ropes and keep everything straight. That means writers and editors are needed to add new content and make sure existing materials are up to date.

      WordPress contributors who work on documentation are responsible for a number of projects. They add articles to the Codex and makes changes to it when necessary. In addition, they work on the contributor handbooks, the WordPress developer website, and inline documentation for the platform itself. All of these resources are invaluable for new WordPress users and veterans alike, so they need to be accurate and current.

      If you have some writing, editing, proofreading, or fact-checking experience under your belt, this is a perfect way to contribute to the platform. Check out the Make WordPress page for the documentation team — you’ll find helpful links to connect with fellow contributors.

      Plugin and Theme Review

      directory-featured-plugins.PNG
      Plugins and themes go through a review process before they’re listed in the official WordPress directories.

      If you’re interested in working with themes and plugins, but don’t want to get involved in development, there’s another avenue to consider — reviewing them. After all, not just any theme or plugin is allowed into the official WordPress directories. Each submission must go through a vetting process to ensure it meets basic requirements and is safe for people to use on their sites.

      There are two separate teams involved in the review process, one for themes and one for plugins. Both check all new submissions against basic guidelines. If you join one of these teams, you’ll be given a specific procedure to follow, although it will still help to have some solid knowledge about how themes and plugins work.

      You can check out the Theme Review Team and Plugin Review Team handbooks on the Make WordPress website, and follow the instructions within for getting involved. The plugin team isn’t always accepting new members, but if it’s currently closed you can bookmark the page and keep an eye on it for future developments.

      Translation and Accessibility

      One of the best things about an online community is that it can easily transcend barriers such as location, nationality, and ability. Just about anyone can contribute to WordPress and make their voice heard, no matter who they are or where they’re from. Similarly, people from all countries and walks of life use WordPress to create and run their websites.

      This means the platform needs to be as flexible and accessible as possible, to meet the needs of various types of users. Two teams in particular help to achieve this goal: the translation and accessibility groups. The translation team, also referred to as the ‘polyglots’, works on adding more languages to WordPress. The accessibility team is focused on making the platform as useful as possible for everyone — regardless of hardware, software, or any sensory or physical impairment.

      These two fields have similar goals but benefit from somewhat different skill sets. If you’re interested in joining the polyglot team, you’ll, of course, want knowledge of at least one other language, along with solid writing and editing skills. As for the accessibility team, it’s largely made up of developers and coders and will most likely start you off by helping with accessibility-related testing and support tickets.

      Community Outreach

      wordcamp-website.PNG
      WordCamps are excellent events for WordPress newbies and experts alike.

      Not everyone is happy to stay behind a computer screen all day. Some people are more interested in getting out and making professional and personal connections. If this sounds like you, it might be worth checking out the WordPress community outreach team.

      As we’ve already talked about, the WordPress community is large, diverse, and spread out geographically. It takes a lot of work to keep everyone on the same page and working towards the same goals. Plus, as WordPress grows, its community does too — and contributors need to make connections with new members and get them excited about the platform.

      The community outreach team handles official WordPress events, such as Meetups and WordCamps. They also run mentorship programs, work hard to attract new contributors to all the Make WordPress teams, and manage various other initiatives. If you have solid people skills and enjoy working with programs and events, check out the team’s current projects. Then jump into their Slack channel or use their contact form to get in touch.

      Other Opportunities

      The fields listed above are just some of the many ways you can get involved as a WordPress contributor. For even more options, check out the main page of the Make WordPress website. You’ll find plenty of other groups looking for members, working on projects such as:

      Finally, if you have an idea for how to contribute to the WordPress community but can’t find a dedicated group, try posting your thoughts and goals in the forums. Chances are, you’ll find like-minded people interested in the same type of work!

      Step 3: Stay Involved in the WordPress Community

      wordpress-meetups.PNG
      WordPress Meetups are held all over the world, bringing contributors and enthusiasts alike together.

      Just as it’s important to keep learning about WordPress while you’re working as a contributor, it’s also crucial to stay involved with the community. You’ve got to (digitally) mix and mingle! This will help to keep you updated about important news and events and makes it easier to find people to collaborate with and to get help from when you need it.

      Even if you’re dedicated to a specific area of contribution, such as translation, you’ll want to occasionally step outside that niche and talk to people involved in other parts of the project. Meeting new people and encountering new ideas this way will help to inform your own work and ensure that everyone is working towards the same goals. Here are a few ways to get — and stay — involved in the community:

      • Continue to frequent your favorite research sources especially forums and blogs.
      • Stay up-to-date on WordPress news and happenings.
      • Keep your eye on the new WordPress Events and News widget in the admin area of your website(s).
      • Consider attending dedicated WordPress events, such as WordCamps and Meetups. This is a great way to meet people, share ideas, and start collaborations. If there aren’t any opportunities in your area, you can always start one yourself!

      Becoming a WordPress contributor takes time and effort — but it’s well worth the investment. You’ll be part of a vast community of people all working towards a common goal, and you’ll have the chance to put your own stamp on the world’s most popular CMS.

      Be Awesome on the Internet

      Join our monthly newsletter for tips and tricks to build your dream website!

      But Wait, There’s More

      If you’ve only ever used WordPress to build and maintain your website, it may surprise you to learn how much goes on behind the scenes. A vast, thriving community is required to keep the platform at its best — including developers, designers, writers, and more. Getting involved in this community is simple, and in exchange, you’ll be met with plenty of opportunities for professional development and growth.

      To get started as a WordPress contributor, you’ll want to:

      1. Conduct some research on the platform and community, learning as much as you can and finding out what areas speak to you.
      2. Decide on one or more fields of contribution that are a match to your skills, interests, and goals.
      3. Stay involved with the WordPress community through forums, blogs, news, and events.

      And remember, if you’re looking for a web host that works seamlessly with WordPress, look no further! DreamHost regularly earns top marks and reviews, giving you the confidence to run your WordPress site with a true web hosting standout. We’ve worked hard to earn this noteworthy recommendation, designing services that make site management a snap. We aim to elevate your WordPress experience with quality tools and powerful resources to ensure peak WordPress performance. Check out our Managed WordPress Hosting plans today!



      Source link

      How To Implement Pagination in MySQL with PHP on Ubuntu 18.04


      The author selected the the Apache Software Foundation to receive a donation as part of the Write for DOnations program.

      Introduction

      Pagination is the concept of constraining the number of returned rows in a recordset into separate, orderly pages to allow easy navigation between them, so when there is a large dataset you can configure your pagination to only return a specific number of rows on each page. For example, pagination can help to avoid overwhelming users when a web store contains thousands of products by reducing the number of items listed on a page, as it’s often unlikely a user will need to view every product. Another example is an application that shows records on a mobile device; enabling pagination in such a case would split records into multiple pages that can fit better on a screen.

      Besides the visual benefits for end-users, pagination makes applications faster because it reduces the number of records that are returned at a time. This limits the data that needs to be transmitted between the client and the server, which helps preserve server resources such as RAM.

      In this tutorial, you’ll build a PHP script to connect to your database and implement pagination to your script using the MySQL LIMIT clause.

      Prerequisites

      Before you begin, you will need the following:

      Step 1 — Creating a Database User and a Test Database

      In this tutorial you’ll create a PHP script that will connect to a MySQL database, fetch records, and display them in an HTML page within a table. You’ll test the PHP script in two different ways from your web browser. First, creating a script without any pagination code to see how the records are displayed. Second, adding page navigation code in the PHP file to understand how pagination works practically.

      The PHP code requires a MySQL user for authentication purposes and a sample database to connect to. In this step you’ll create a non-root user for your MySQL database, a sample database, and a table to test the PHP script.

      To begin log in to your server. Then log in to your MySQL server with the following command:

      Enter the root password of your MySQL server and hit ENTER to continue. Then, you’ll see the MySQL prompt. To create a sample database, which we will call test_db in this tutorial, run the following command:

      You will see the following output:

      Output

      Query OK, 1 row affected (0.00 sec)

      Then, create a test_user and grant the user all privileges to the test_db. Replace PASSWORD with a strong value:

      • GRANT ALL PRIVILEGES ON test_db.* TO 'test_user'@'localhost' IDENTIFIED BY 'PASSWORD';

      Output

      Query OK, 1 row affected (0.00 sec)

      Reload the MySQL privileges with:

      Output

      Query OK, 1 row affected (0.00 sec)

      Next, switch to the test_db database to start working directly on the test_db database:

      Output

      Database changed

      Now create a products table. The table will hold your sample products—for this tutorial you’ll require only two columns for the data. The product_id column will serve as the primary key to uniquely identify each record. You’ll use the product_name field to differentiate each item by name:

      • Create table products (product_id BIGINT PRIMARY KEY, product_name VARCHAR(50) NOT NULL ) Engine = InnoDB;

      Output

      Query OK, 0 rows affected (0.02 sec)

      To add ten test products to the products table run the following SQL statements:

      • Insert into products(product_id, product_name) values ('1', 'WIRELESS MOUSE');
      • Insert into products(product_id, product_name) values ('2', 'BLUETOOTH SPEAKER');
      • Insert into products(product_id, product_name) values ('3', 'GAMING KEYBOARD');
      • Insert into products(product_id, product_name) values ('4', '320GB FAST SSD');
      • Insert into products(product_id, product_name) values ('5', '17 INCHES TFT');
      • Insert into products(product_id, product_name) values ('6', 'SPECIAL HEADPHONES');
      • Insert into products(product_id, product_name) values ('7', 'HD GRAPHIC CARD');
      • Insert into products(product_id, product_name) values ('8', '80MM THERMAL PRINTER');
      • Insert into products(product_id, product_name) values ('9', 'HDMI TO VGA CONVERTER');
      • Insert into products(product_id, product_name) values ('10', 'FINGERPRINT SCANNER');

      You’ll see this output:

      Output

      Query OK, 1 row affected (0.02 sec)

      Verify that the products were inserted to the table by running:

      You’ll see the products in your output within the two columns:

      Output

      +------------+-----------------------+ | product_id | product_name | +------------+-----------------------+ | 1 | WIRELESS MOUSE | | 2 | BLUETOOTH SPEAKER | | 3 | GAMING KEYBOARD | | 4 | 320GB FAST SSD | | 5 | 17 INCHES TFT | | 6 | SPECIAL HEADPHONES | | 7 | HD GRAPHIC CARD | | 8 | 80MM THERMAL PRINTER | | 9 | HDMI TO VGA CONVERTER | | 10 | FINGERPRINT SCANNER | +------------+-----------------------+ 10 rows in set (0.00 sec)

      Exit MySQL:

      With the sample database, table, and test data in place, you can now create a PHP script to display data on a web page.

      Now you’ll create a PHP script that connects to the MySQL database that you created in the previous step and list the products in a web browser. In this step, your PHP code will run without any form of pagination to demonstrate how non-split records show on a single page. Although you only have ten records for testing purposes in this tutorial, seeing the records without pagination will demonstrate why segmenting data will ultimately create a better user experience and put less burden on the server.

      Create the PHP script file in the document root of your website with the following command:

      • sudo nano /var/www/html/pagination_test.php

      Then add the following content to the file. Remember to replace PASSWORD with the correct value of the password that you assigned to the test_user in the previous step:

      /var/www/html/pagination_test.php

      <?php
      
      try {
      
          $pdo = new PDO("mysql:host=localhost;dbname=test_db", "test_user", "PASSWORD");
          $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
      
          $sql="select * from products";
      
          $stmt = $pdo->prepare($sql);
      
          $stmt->execute();
      
          echo "<table border='1' align='center'>";
      
          while ( ($row = $stmt->fetch(PDO::FETCH_ASSOC) ) !== false) {
              echo "<tr>";
      
              echo "<td>".$row['product_id']."</td>";
      
              echo "<td>".$row['product_name']."</td>";
      
              echo "</tr>";
      
          }
      
          echo "</table>";
      
      }
      
        catch(PDOException $e)
      
      {
          echo  $e->getMessage();
      }
      
      ?>
      

      Save the file by pressing CTRL+X, Y, and ENTER.

      In this script you’re connecting to the MySQL database using the PDO (PHP Data Object) library with the database credentials that you created in Step 1.

      PDO is a light-weight interface for connecting to databases. The data access layer is more portable and can work on different databases with just minor code rewrites. PDO has greater security since it supports prepared statements—a feature for making queries run faster in a secure way.

      Then, you instruct the PDO API to execute the select * from products statement and list products in an HTML table without pagination. The line $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false); ensures that the data types are returned as they appear in the database. This means that PDO will return the product_id as an integer and the product_name as a string. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); instructs PDO to throw an exception if an error is encountered. For easier debugging you’re catching the error inside the PHP try{}...catch{} block.

      To execute the /var/www/html/pagination_test.php PHP script file that you’ve created, visit the following URL replacing your-server-IP with the public IP address of your server:

      http://your-server-IP/pagination_test.php
      

      You’ll see a page with a table of your products.

      MySQL Records Displayed with a PHP script - No Pagination

      Your PHP script is working as expected; listing all products on one page. If you had thousands of products, this would result in a long loop as the products are fetched from the database and rendered on the PHP page.

      To overcome this limitation, you will modify the PHP script and include the MySQL LIMIT clause and some navigation links at the bottom of the table to add pagination functionality.

      In this step your goal is to split the test data into multiple and manageable pages. This will not only enhance readability but also use the resources of the server more efficiently. You will modify the PHP script that you created in the previous step to accommodate pagination.

      To do this, you’ll be implementing the MySQL LIMIT clause. Before adding this to the script, let’s see an example of the MySQL LIMIT syntax:

      • Select [column1, column2, column n...] from [table name] LIMIT offset, records;

      The LIMIT clause takes two arguments as shown toward the end of this statement. The offset value is the number of records to skip before the first row. records sets the maximum number of records to display per page.

      To test pagination, you’ll display three records per page. To get the total number of pages, you must divide the total records from your table with the rows that you want to display per page. You then round the resulting value to the nearest integer using PHP Ceil function as shown in the following PHP code snippet example:

      $total_pages=ceil($total_records/$per_page);
      

      Following is the modified version of the PHP script with the full pagination code. To include the pagination and navigation codes, open the /var/www/html/pagination_test.php file:

      • sudo nano /var/www/html/pagination_test.php

      Then, add the following highlighted code to your file:

      /var/www/html/pagination_test.php

      <?php
      
      try {
      
          $pdo = new PDO("mysql:host=localhost;dbname=test_db", "test_user", "PASSWORD");
          $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
      
          /* Begin Paging Info */
      
          $page=1;
      
          if (isset($_GET['page'])) {
              $page=filter_var($_GET['page'], FILTER_SANITIZE_NUMBER_INT);
          }
      
          $per_page=3;
      
          $sqlcount="select count(*) as total_records from products";
          $stmt = $pdo->prepare($sqlcount);
          $stmt->execute();
          $row = $stmt->fetch();
          $total_records= $row['total_records'];
      
          $total_pages=ceil($total_records/$per_page);
      
          $offset=($page-1)*$per_page;
      
          /* End Paging Info */
      
          $sql="select * from products limit $offset,$per_page";
      
          $stmt = $pdo->prepare($sql);
      
          $stmt->execute();
      
      
          echo "<table border='1' align='center'>";
      
          while ( ($row = $stmt->fetch(PDO::FETCH_ASSOC) ) !== false) {
              echo "<tr>";
      
              echo "<td>".$row['product_id']."</td>";
      
              echo "<td>".$row['product_name']."</td>";
      
              echo "</tr>";
      
          }
      
          echo "</table>";
      
          /* Begin Navigation */
      
          echo "<table border='1' align='center'>";
      
          echo "<tr>";
      
          if( $page-1>=1) {
              echo "<td><a href=".$_SERVER['PHP_SELF']."?page=".($page-1).">Previous</a></td>";
          }
      
          if( $page+1<=$total_pages) {
              echo "<td><a href=".$_SERVER['PHP_SELF']."?page=".($page+1).">Next</a></td>";
          }
      
          echo "</tr>";
      
          echo "</table>";
      
          /* End Navigation */
      
      }
      
      catch(PDOException $e) {
              echo  $e->getMessage();
      }
      
      ?>
      

      In your file you’ve used additional parameters to execute paging:

      • $page : This variable holds the current page in your script. When moving between the pages, your script retrieves a URL parameter named page using the $_GET['page'] variable.
      • $per_page: This variable holds the maximum records that you want to be displayed per page. In your case, you want to list three products on each page.
      • $total_records: Before you list the products, you’re executing a SQL statement to get a total count of records in your target table and assigning it to the $total_records variable.
      • $offset: This variable represents the total records to skip before the first row. This value is calculated dynamically by your PHP script using the formula $offset=($page-1)*$per_page. You may adapt this formula to your PHP pagination projects. Remember you can change the $per_page variable to suit your needs. For instance, you might change it to a value of 50 to display fifty items per page if you’re running a website or another amount for a mobile device.

      Again, visit your IP address in a browser and replace your_server_ip with the public IP address of your server:

      http://your_server_ip/pagination_test.php
      

      You’ll now see some navigation buttons at the bottom of the page. On the first page, you will not get a Previous button. The same case happens on the last page where you will not get the Next page button. Also, note how the page URL parameter changes as you visit each page.

      MySQL Records Displayed with a PHP script with Pagination - Page 1

      MySQL Records Displayed with a PHP script with Pagination - Page 2

      Final page of MySQL Records Displayed with a PHP script with Pagination - Page 4

      The navigation links at the bottom of the page are achieved using the following PHP code snippet from your file:

      /var/www/html/pagination_test.php

      . . .
          if( $page-1>=1) {
              echo "<td><a href=".$_SERVER['PHP_SELF']."?page=".($page-1).">Previous</a></td>";
          }
      
          if( $page+1<=$total_pages) {
              echo "<td><a href=".$_SERVER['PHP_SELF']."?page=".($page+1).">Next</a></td>";
          }
      . . .
      

      Here, the $page variable represents the current page number. Then, to get the previous page, the code will minus 1 from the variable. So, if you’re on page 2, the formula (2-1) will give you a result of 1 and this will be the previous page to appear in the link. However, keep in mind that it will only show the previous page if there is a result greater or equal to 1.

      Similarly, to get to the next page, you add one to the $page variable and you must also make sure that the $page result that we append to the page URL parameter is not greater than the total pages that you’ve calculated in your PHP code.

      At this point, your PHP script is working with pagination and you are able to implement the MySQL LIMIT clause for better record navigation.

      Conclusion

      In this tutorial, you implemented paging in MySQL with PHP on an Ubuntu 18.04 server. You can use these steps with a larger recordset using the PHP script to include pagination. By using pagination on your website or application you can create better user navigation and optimum resource utilization on your server.

      From here you could consider further optimization for your database and other database tasks with these tutorials:



      Source link

      How to Create a Website for Your Event (In 4 Steps)


      Planning events can be both fun and strenuous. Whether you’re working on the fundraiser of the year, a huge wedding, or an academic conference, you might be wondering how you can create an appealing online presence for the upcoming event.

      Fortunately, creating an event website using WordPress can be fast and easy. As an open-source Content Management System (CMS), WordPress has a ton of built-in flexibility. Additionally, the platform has a vast community of helpful users and developers that you can reach out to for help.

      In this article, we’re going to discuss why WordPress is a smart choice for your event website. Then we’ll walk you through all the steps needed to create your own event website using WordPress. Let’s jump right in!

      Why You Should Consider a WordPress Site for Your Event

      There are many reasons WordPress is an excellent platform for building an event website. For example, it offers both ease of editing and a high level of flexibility. Plus, the platform is always free to download.

      What’s more, since WordPress is built using open-source code, developers all over the world have added onto the platform’s core functionality with plugins. This means there are many options for enhancing your site with event-specific, niche plugins that can help you easily track, promote, and share your event in order to boost registrations.

      Another benefit to building with this CMS is that it doesn’t matter how big or how small your event might be — WordPress always fits like a glove! Fortunately, building your event website using WordPress doesn’t have to be difficult at all.

      WordPress + DreamHost

      Our automatic updates and strong security defenses take server management off your hands so you can focus on building a great event website.

      How to Create a WordPress Site for Your Event (In 4 Steps)

      To get started with your WordPress event site, all you need to do is follow these four steps. Each will help you get up and running as quickly as possible, so you can move on to planning and hosting the event itself.

      1. Choose a Secure and Professional Hosting Platform

      While the WordPress software is free, you’ll still need to host your site somewhere. Choosing a web host can seem overwhelming at first, but it’s an essential first step in getting your event site started.

      A web host is where all of your site’s data is stored, along with the files that create the functionality you’ll need to manage your event. There are a few things to consider when choosing your host since there are lots of options out there.

      You’ll want to make sure the host you choose has the support you might need for certain types of events. You may need to accommodate a live stream, for example, or your event might require higher bandwidth for heavy registration traffic.

      Here at DreamHost, we have several Virtual Private Server (VPS) options that can suit a wide variety of event planning needs.

      DreamHost VPS pricing.

      We recommend really getting a feel for all the different types of hosting out there. That way, you can make sure your event website is stored in the most secure, high-performance location possible.

      2. Select a Theme to Suit Your Event

      Once you’ve installed WordPress on your hosting plan, you can move on to some of the more exciting parts of building a website!

      Choosing a theme can be a lot of fun, and it’s also a vital step. That’s especially true if you are looking to create a cohesive brand or send out a certain “vibe” about your event.

      There are two main ways you can obtain WordPress themes, including:

      • Downloading free themes from the WordPress Theme Directory
      • Purchasing premium themes from a theme marketplace or directly from a developer

      Themes often come with built-in functionality or features that you’ll want to understand before installing them. If you know you need a certain kind of layout, footer, or sidebar, for example, you’ll want to make sure the theme you pick can handle that type of design.

      Some of the free themes available in the directory are nearly as packed with features as premium themes that come with a price tag. Reading their reviews and checking to see when each theme was last updated are smart ways to decide which is best for your site.

      Of course, it’s also important to remember that sometimes niche themes can be more helpful than general, all-purpose themes. For example, ShowThemes offers event-specific WordPress themes and lets you search its database by feature set so you can find exactly what you’re looking for.

      The ShowThemes home page.

      ShowThemes covers the full spectrum of possible events you might want to promote. For instance, if you just need a one-page site for a conference, the Fudge theme is a solid option. Not only is it already optimized for mobile devices, but it also has a clear and easy-to-customize design for your Call-to-Action.

      The Fudge theme.

      Starting with a theme designed for the type of event you’re promoting can save you a lot of time, so it’s well worth considering.

      3. Add Event and E-Commerce Plugins to Manage Registration

      There are a few more universal aspects of event planning to keep in mind while building your WordPress event site. Typically, events require some kind of registration process, guest list, or check-in management (just to name a few examples).

      Whether or not your event is free-of-charge or requires payment, adding event and e-commerce plugins to your site can be extremely helpful. There are a number of ways to build in the functionality you’ll need to handle ticket sales or registrations.

      Event Espresso, for instance, is an all-in-one plugin solution that covers everything from setting up a registration form to using payment gateways.

      The Event Espresso plugin.

      While the free version provides plenty of functionality, you can purchase Event Espresso’s premium tier if you’re interested in add-on features such as printable tickets, ticket scanning, and waitlists.

      If you need a plugin that specializes in managing a guest list and registration data, on the other hand, you might want to check out the RSVP and Event Management plugin.

      The RSVP and Event Management plugin.

      Additionally, you can maximize WordPress’ flexibility by using plugins that make it possible to connect to outside event software, such as EventBrite, to help you manage your event. While this method requires you to have an account with the platform, it’s still an excellent option if you have specific event management applications you know and love.

      4. Promote Your Event on Social Media

      Once you’ve built your event site, you’ll likely want to start getting the word out and encouraging registrations. It’s no secret that social media is probably the best way to share your event with your target audience, as widely or as privately as you want.

      One of the most straightforward ways to promote your event on social media is to let your website visitors do it for you, through adding social sharing buttons to your website. You can add on a plugin like Sassy Social Share, for example, and choose from over 100 social media and bookmarking site buttons to add to your site.

      The Sassy Social Share plugin.

      If you want to take things a step further, and proactively push your event content and site updates to a variety of social media sites, you can check out the free plugin Blog2Social. This tool gives you the option to set up automatic posts from your website to 14 different social networks.

      The Blog2Social plugin.

      With Blog2Social, you can also cross-post content, schedule updates, and automatically post new content. Additionally, you can customize your posts with comments and hashtags, for even more engagement and appeal.

      You can even enable guests to register for your event via their existing social media accounts. Adding the Social Login plugin to your event site makes that simple.

      The Social Login plugin.

      Whether you’re looking to push content to social media accounts, or pull in guests and registrations via social channels, adding some of these helpful plugins to your event site can help you stand out from the pack and attract attention.

      Easy Event Marketing

      If you’ve been worried about how to get your event website off the ground, while also planning for all your other event-related needs, we hope this step-by-step guide has helped to ease your burden a bit. WordPress can help you get your site up and running quickly, which leaves you plenty of time to focus on all the other details that make for a great event.

      Here at DreamHost, WordPress is always invited to the party. Check out our WordPress hosting plans and get your event website online today!



      Source link