Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/04/2021 in all areas

  1. The concept is called "pagination". For most people that has to do with database queries, but with your API calls it's still very similar in execution. You need to get the desired page number from the form; if you want Prev and Next buttons then you could include the page number in the form and know which button means -1 or +1, but easier would be to make the buttons have the actual page number as their values. Processing the form to get the page number has to happen before you use the API, of course. Your $page > 1 and $page < $result->pages checks are good for deciding whether to show the Prev and Next buttons, but since you need the page number before you use the API, you can't use the results of that API call to decide what to do. My suggestion is: 1. Get the $page from the form data (if it is >=1) or use 1 if there wasn't a valid number given 2. Call the API with the page number 3. Show the results like normal 4. In the form, if $page > 1 then show the Prev button, and if $page < number of pages then show the Next button 5. For the two buttons, give them a name of "page" and a value of $page - 1/$page + 1 appropriately: when someone clicks either button then that will submit a "page" in the form data for your code to use
    1 point
  2. You need to read up on database normalization. What you need to do is have a table where each category is a row, not a column and then join that to your other tables.
    1 point
  3. Your project contains libraries that require PHP 7.4 or newer but your server is running PHP 7.3. The system you used to develop the project must have a newer version of PHP, so when you ran composer there and generated the composer.lock file it did so assuming PHP 7.4 or newer was being used. You should update your server to a newer PHP version. For the future, you should also make sure your development system matches your production system as closely as possible.
    1 point
  4. @gizmola and I both gave you code that you have not implemented. You should spend some time going through this PDO tutorial. Making a PDO connection is one of the simplest things you would ever need to do. https://phpdelusions.net/pdo This is all that is required to make a PDO connection. Anything you do beyond this, you should know exactly WHY you are doing more. $con = new PDO("mysql:host=localhost;dbname=test", 'root', '');
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.