php - SQL query Duplicates -
i facing problem unable find out why happening, i've spent many hours couldn't find resolution, highly appreciate help.
well case is:
i pulling columns tracks table , order 2 columns tracks.spotlight , tracks.id
spotlight column contains 1 or 0 values while tracks id's 1,2,3,4 ... 500 unique,
and have perpage limit of 20 records.
now when open these records pull correctly in browser wanted first 20 records show absolutely perfect , spotlight has value 1 on top (that's wanted).
now when load more (next set of 20 records)
it repeating spotlight track again + showing rest track id's in desc order.
the problem want prevent spotlight repeat on every page loop.
can me doing wrong.
thanks alot guys,
here code
function searchtracks($start, $value) { // if $start value 0, empty query; if($start == 0) { $start = ''; } else { // else, build query $start = 'and tracks.id db->real_escape_string($start).'\''; } $query = sprintf("select * `tracks`, `users` (`tracks`.`title` '%s' or `tracks`.`description` '%s' or `tracks`.`tag` '%s' or `tracks`.`record` '%s' ) , `tracks`.`uid` = `users`.`idu` %s , `tracks`.`public` = 1 order tracks.spotlight desc, tracks.id desc limit %s", '%'.$this->db->real_escape_string($value).'%', '%'.$this->db->real_escape_string($value).'%', '%'.$this->db->real_escape_string($value).'%', '%'.$this->db->real_escape_string($value).'%', $start, ($this->per_page + 1)); return $this->gettracks($query, 'searchtracks', '\''.$value.'\''); }
Comments
Post a Comment