Author Topic: Paging Calculation  (Read 7201 times)

0 Members and 1 Guest are viewing this topic.

skiemor

  • Guest
Paging Calculation
« on: January 03, 2008, 06:59:31 AM »
Hello @ all,
my result by clicking "All images":

Search Found: 121 image(s) on 8.0666666666667 page(s). Displayed: image 1 to 15.
How can I change that to a whole number and how can I exclude *.mp3 from search?

Best,

Chris.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Paging Calculation
« Reply #1 on: January 03, 2008, 03:19:54 PM »
You ask 2 question for 1 topic ... please create two each topic for request ...

In search.php file,

find:

Code: [Select]
for ($i = 0; $i < sizeof($split_words); $i++) {
    if ($split_words[$i] == "and" || $split_words[$i] == "und" || $split_words[$i] == "or" || $split_words[$i] == "oder" || $split_words[$i] == "not") {
      $search_word_cache[$i] = ($search_terms) ? "and" : $split_words[$i];
    }
    else {
      $sql = "SELECT m.image_id
              FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id
              $match_field_sql";
      $result = $site_db->query($sql);
      $search_word_cache[$i] = array();
      while ($row = $site_db->fetch_array($result)) {
        $search_word_cache[$i][$row['image_id']] = 1;
      }
      $site_db->free_result();
    }
  }

replace:

Code: [Select]
for ($i = 0; $i < sizeof($split_words); $i++) {
    if ($split_words[$i] == "and" || $split_words[$i] == "und" || $split_words[$i] == "or" || $split_words[$i] == "oder" || $split_words[$i] == "not") {
      $search_word_cache[$i] = ($search_terms) ? "and" : $split_words[$i];
    }
    else {
        $split_words[$i] = str_replace("*", "%", $split_words[$i]);
        $split_words[$i] = addslashes($split_words[$i]);        
            $sql = "SELECT m.image_id, i.image_thumb_file, i.image_media_file
            FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m, " . IMAGES_TABLE . " i)
            WHERE w.word_text LIKE '" . $split_words[$i] . "'
            AND m.word_id = w.word_id AND m.image_id = i.image_id
            $match_field_sql";
            $result = $site_db->query($sql);
            $search_word_cache[$i] = array();
            while ($row = $site_db->fetch_array($result)) {
                if (!preg_match("/\.mp3$/", get_file_name(basename($search_word_cache[$i][$row['image_thumb_file']]))) || !preg_match("/\.mp3$/", get_file_name(basename($search_word_cache[$i][$row['image_media_file']])))) {
                   $search_word_cache[$i][$row['image_id']] = 1;
                }
            }
            $site_db->free_result();        
    }
  }

For paging ... hum ... includes/paging.php file,

find:

Code: [Select]
$this->total_pages = ceil($this->num_rows_all / $this->perpage);

replace:

Code: [Select]
$this->total_pages = number_format($this->num_rows_all / $this->perpage, 2);
« Last Edit: February 18, 2011, 02:42:01 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Paging Calculation
« Reply #2 on: January 03, 2008, 04:05:38 PM »
You ask 2 question for 1 topic ... please create two each topic for request ...

In search.php file,

find:

Code: [Select]
for ($i = 0; $i < sizeof($split_words); $i++) {
    if ($split_words[$i] == "and" || $split_words[$i] == "und" || $split_words[$i] == "or" || $split_words[$i] == "oder" || $split_words[$i] == "not") {
      $search_word_cache[$i] = ($search_terms) ? "and" : $split_words[$i];
    }
    else {
      $sql = "SELECT m.image_id
              FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id
              $match_field_sql";
      $result = $site_db->query($sql);
      $search_word_cache[$i] = array();
      while ($row = $site_db->fetch_array($result)) {
        $search_word_cache[$i][$row['image_id']] = 1;
      }
      $site_db->free_result();
    }
  }

replace:

Code: [Select]
for ($i = 0; $i < sizeof($split_words); $i++) {
    if ($split_words[$i] == "and" || $split_words[$i] == "und" || $split_words[$i] == "or" || $split_words[$i] == "oder" || $split_words[$i] == "not") {
      $search_word_cache[$i] = ($search_terms) ? "and" : $split_words[$i];
    }
    else {
        $split_words[$i] = str_replace("*", "%", $split_words[$i]);
        $split_words[$i] = addslashes($split_words[$i]);
        if (!eregi("\.mp3$", $split_words[$i])) {
            $sql = "SELECT m.image_id
            FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
            WHERE w.word_text LIKE '" . $split_words[$i] . "'
            AND m.word_id = w.word_id
            $match_field_sql";
            $result = $site_db->query($sql);
            $search_word_cache[$i] = array();
            while ($row = $site_db->fetch_array($result)) {
                $search_word_cache[$i][$row['image_id']] = 1;
            }
            $site_db->free_result();
        }
    }
  }

For paging ... hum ... includes/paging.php file,

find:

Code: [Select]
$this->total_pages = ceil($this->num_rows_all / $this->perpage);

replace:

Code: [Select]
$this->total_pages = number_format($this->num_rows_all / $this->perpage, 2);

Thanks a lot, Thunderstrike!
paging: now of example 7.00 pages --> should be 7 pages

message search.php:
Parse error: parse error, unexpected '}' in /homepages/26/d83193504/htdocs/birdgallery/search.php on line 137

    $is_first_word = 0;
  }

  $search_id['image_ids'] = "";
  foreach ($image_id_list as $key => $val) {
    $search_id['image_ids'] .= (($search_id['image_ids'] != "") ? ", " : "").$key;
  }
  unset($image_id_list);
137:}

if ($search_new_images && $show_result == 1) {
  $search_id['search_new_images'] = 1;

Chris.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Paging Calculation
« Reply #3 on: January 03, 2008, 04:13:29 PM »
You no replace right of code ... I no can reproduce problem ... I no see error after replace ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Paging Calculation
« Reply #4 on: January 03, 2008, 04:24:54 PM »
yes, I have repeated replacing --> no message, but *.mp3 in search ;-)

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Paging Calculation
« Reply #5 on: January 03, 2008, 04:41:28 PM »
Ok, I edit post for replace. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Paging Calculation
« Reply #6 on: January 03, 2008, 05:32:32 PM »
Oh  8O

I get why is no work for check MP3. Now is fix. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Paging Calculation
« Reply #7 on: January 04, 2008, 01:24:33 PM »
Hello @ all,
my result by clicking "All images":

Search Found: 121 image(s) on 8.0666666666667 page(s). Displayed: image 1 to 15.
How can I change that to a whole number and how can I exclude *.mp3 from search?

Best,

Chris.

It's the number 121.  --> if 122 everything is all right.

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Paging Calculation
« Reply #8 on: January 04, 2008, 01:31:07 PM »
also ich hab das gerade bei mir getestet...

Gefunden: 21 Bild(er) auf 7 Seite(n). Angezeigt: Bild 1 bis 3.  (3 pro seite)
Gefunden: 21 Bild(er) auf 4 Seite(n). Angezeigt: Bild 1 bis 6.  (6 pro seite)
Gefunden: 21 Bild(er) auf 2 Seite(n). Angezeigt: Bild 1 bis 15. (15 pro seite)

ich weiss nicht wie es bei den anderen ist..
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

skiemor

  • Guest
Re: Paging Calculation
« Reply #9 on: January 04, 2008, 01:33:24 PM »
Hm, und 121? :?
Kann ich mir nicht erklären, wie so einiges nicht! ;-)

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Paging Calculation
« Reply #10 on: January 04, 2008, 01:45:48 PM »
Gefunden: 121 Bild(er) auf 9 Seite(n). Angezeigt: Bild 1 bis 15.
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

skiemor

  • Guest
Re: Paging Calculation
« Reply #11 on: January 04, 2008, 01:47:31 PM »
;-) ;-)

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Paging Calculation
« Reply #12 on: January 04, 2008, 01:51:04 PM »
weiss nicht ob du deine includes/paging.php vielleicht geändert hast..

wenn doch, probiere es mit der original version
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

skiemor

  • Guest
Re: Paging Calculation
« Reply #13 on: January 04, 2008, 01:55:10 PM »
Danke Nicky, hab' getauscht. Alles wieder im Lot, bis zum nächsten "Fehler" ;-)