Welcome Guest, Not a member yet? Register   Sign In
passing name instead of id
Reply
#12

Right before
PHP Code:
$data["links"] = $this->pagination->create_links(); 

insert this:
PHP Code:
echo '<pre>';
print_r($config);
echo 
'</pre>';
die(); 
Reply
#13

(This post was last modified: 10-26-2019, 07:37 AM by manigopal.)

(10-26-2019, 02:30 AM)Wouter60 Wrote: Right before
PHP Code:
$data["links"] = $this->pagination->create_links(); 

insert this:
PHP Code:
echo '<pre>';
print_r($config);
echo 
'</pre>';
die(); 


Output for this :

Array
(
    [full_tag_open] =>
  •     [full_tag_close] =>

    [num_tag_open] =>
[*]
    [num_tag_close] =>

    [cur_tag_open] =>
[*]
    [cur_tag_close] => (current)

    [next_tag_open] =>
[*]
    [next_tag_close] =>

    [prev_tag_open] =>
[*]
    [prev_tag_close] =>

    [first_tag_open] =>
[*]
    [first_tag_close] =>

    [last_tag_open] =>
[*]
    [last_tag_close] =>

    [base_url] => http://[::1]/ciprojects/showtime/movies/genre
    [total_rows] => Array
        (
        )

    [first_url] => http://[::1]/ciprojects/showtime/movies/genre
    [per_page] => 18
    [uri_segment] => 3
    [use_page_numbers] => 1
)

i have doubt on this line64 @ Movies_genre.php on passing parameter,

$data['movies_fetched'] = $this->Model_movie_genre->movies_by_genre($genre_type, $config["per_page"], $offset);

Note : All Gitlab files are updated regularly.
Reply
#14

$config['total_rows'] should be a numeric value (0 or greater), not an array!
Reply
#15

(This post was last modified: 10-26-2019, 09:04 AM by manigopal.)

(10-26-2019, 08:48 AM)Wouter60 Wrote: $config['total_rows'] should be a numeric value (0 or greater), not an array!

so, how could we pass this

$config["total_rows"] = $this->Model_movie_genre->movies_by_genre($genre_type);

actually i use the same script for movies page (2nd menu) it works fine, in this movies-genre i pass a parameter $genre_type which makes not working. If possible could you @Wouter60 have a look into all MVC files and shoot me which causes the trouble.

Files @GitLab
Reply
#16

(This post was last modified: 10-26-2019, 10:26 PM by manigopal.)

Live Website @ http://cishowtime.22web.org

Pagination works fine on #Movies page @ http://cishowtime.22web.org/movies

Resource files of #Movies page :
Model file => Model_movie.php
View file => view_movies.php
Controller file => Movies.php


Issue on #MoviesGenre page @ http://cishowtime.22web.org/movies/genre/Action

Resource files of #MoviesGenre page :
Model file => Model_movie_genre.php
View file => view_movies_genre.php
Controller file => Movies_genre.php

MVC files of Movies(which works fine) & MoviesGenre(which has issue) @ https://gitlab.com/manigopal/ci-projects...r/Showtime
Reply
#17

Pagination works fine on #Movies page @ http://cishowtime.22web.org/movies

i have added / passed parameter for genre in Movies_genre.php
then its not working.,
Reply
#18

Your controller has this line:
PHP Code:
$config["total_rows"] = $this->Model_movie_genre->movies_by_genre($genre_type); 

The model function:
PHP Code:
public function movies_by_genre($genre_type)
{
    $query $this->db->query("SELECT * FROM movies_info WHERE movie_genre=? ORDER BY movie_id DESC", array('movie_genre'=>$genre_type));
    return $query->result_array();

This function always returns an array (an empty array if there are no results). Which is wrong, because $config['total_rows'] must be a numeric value (0 or greater) to make the pagination work.

Create a new function in the model:
PHP Code:
public function movie_count($genre_type)
{
  return $this->db->where('movie_genre'$genre_type)->count_all_results('movies_info');


In the controller:
PHP Code:
$config["total_rows"] = $this->Model_movie_genre->movie_count($genre_type); 
Reply
#19

(This post was last modified: 10-27-2019, 07:20 AM by manigopal. Edit Reason: elaborating )

Okay,
what about this line is this right ?

$data['movies_fetched'] = $this->Model_movie_genre->movie_count($config["per_page"], $offset);

@Movies_genre.php ~ controller file, since we pass a parameter called $genre_type in movie_count function at Model page.
Reply
#20

Quote:what about this line is this right ?
Something is telling me that this line can't be correct, otherwise you wouldn't be asking, would you?

It appears to me that you don't understand the concept of php functions.
Imagine a function as a kitchen scale with a basket on it, and that you want to weigh potatoes. You put some potatoes into the basket; the scale will return (tell you) the weight in ounces.
If you pour milk into the basket, along with 6 bananas, you'll end up with a mess. The milk won't stay in the basket. And the scale won't return the weight of potatoes, because you didn't put any potatoes in it.
The values that you pass to a function should match the parameters the function expects to be passed (in number and in value type).
The return value of the function should match the (type of) value that's being expected by the line that calls the function.
Don't mess around with that.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB