GithubHelp home page GithubHelp logo

Comments (2)

omar-elhamedy avatar omar-elhamedy commented on August 12, 2024 1

Hi @iBringit Thanks for your reply,
Please take a look at this code

// This is the code to get the page number from the URL
if(isset($_GET['page'])){
    $page = $_GET['page'];
} else {
    $page = 1;
}

if($page == '' || $page == 1){
    $page1 = 0;
}else{
    $page1 = ($page*10)-10;

}

//This is my code for the search

// and the $query is a _GET from the URL

$multiSearchResults = $tmdb->multiSearch($query);

foreach($multiSearchResults as $mediaType => $searchResults){
        foreach($searchResults as $searchResult) {
            if($searchResult->getMediaType() === 'movie') {
               echo" <div class='gridViewItem'>
                        <a href='/movies/movie?id=". $searchResult->getID() ."'><img class='backup_picture' id='poster' src='http://image.tmdb.org/t/p/original". $searchResult->getPoster() ."'></a>
                        <a href='/movies/movie?id=".$searchResult->getID()."'><div class='gridViewInfo'>"
                                . $searchResult->getTitle() .
                               "</div></a>


                        </div>";
            }}};

This code only show me the search result for the first page only from the API and I want to make a pagination on my website with each page show the results associated with the page number .

from tmdb_v3-php-api-.

iBringit avatar iBringit commented on August 12, 2024

you need to supply an array for foreach statement, instead you are requesting a key value..

try

foreach ($result as $data)

// then fetch the results here

remember $result returns an array you can fetch within the foreach statement as $ data

from tmdb_v3-php-api-.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.