Posted by aaa Mon 26th Feb 2007 22:11 - Syntax is PHP - 46 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers
PHP parser reported no syntax errors in this post!
Description:
hm..

  1. /* sort user interface */
  2. $_sort = isset($_GET['sort']) && in_array($_GET['sort'],array("id","title","rate","genre","seen")) ? $_GET['sort'] : "id";
  3. $_sortdir = isset($_GET['sortdir']) && in_array($_GET['sortdir'],array("asc","desc")) ? $_GET['sortdir'] : "asc";
  4.  
  5.  
  6. /* query MySQL */
  7. if (empty($_GET['search'])) {
  8.  $query = $_class['mysql']->cf_query(
  9.   $_db['database'],
  10.   "",
  11.   "select
  12.    `id`,
  13.    `overview`,
  14.    `title`,
  15.    `rate`,
  16.    `genre`,
  17.    `seen`
  18.   from
  19.    `log`
  20.   order by
  21.    '".$_class['mysql']->cf_safe($_sort)."'
  22.   ".$_sortdir."
  23.   limit
  24.    ".(($_pagenr-1)*100).",100
  25. ");
  26. } else {
  27.  $_search = htmlentities($_GET['search']);
  28.  $_search = urlencode($_search);
  29.  $_search = str_replace("%2A","%",$_search);
  30.  
  31.  $query = $_class['mysql']->cf_query(
  32.   $_db['database'],
  33.   "",
  34.   "select
  35.    `id`,
  36.    `overview`,
  37.    `title`,
  38.    `rate`,
  39.    `genre`,
  40.    `seen`
  41.   from
  42.    `log`
  43.   where
  44.    `title`
  45.   like
  46.    '%".$_class['mysql']->cf_safe($_search)."%'
  47.   order by
  48.    '".$_class['mysql']->cf_safe($_sort)."'
  49.   ".($_sort == "id"?"desc":"")."
  50.   limit
  51.    ".(($_pagenr-1)*100).",100
  52. ");
  53. }
  54.  
  55.  
  56. class="main">
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  

  66. PermaLink to this entry https://pastebin.co.uk/11032
    Posted by aaa Mon 26th Feb 2007 22:11 - Syntax is PHP - 46 viewsRun this post in the PHP shell
    Download | New Post | Modify | Hide line numbers

     

    Comments: 1

    by: on: Tue Feb 27 18:22:35 2007

    class Stupidsortproblem{

    public $sortBy;
    public $sortDir;
    public $limit;

    public $query;
    public $debug = false;

    public $thArray = array('Movie Title' => 'title',
    'Dice Rate' => 'rate',
    'Genre' => 'genre',
    'Seen' => 'seen');
    function __construct(){
    $this->pull_GET_Vars();
    $this->craft_Query();
    $this->result = mysql_query($this->query);
    if($this->debug === true){
    if(!$this->result){ print $this->query; }
    }
    $this->display_Results();
    }

    function pull_GET_Vars(){
    $this->sortBy = (isset($_GET['sort']) &&
    !empty($_GET['sort'])) ? $_GET['sort'] : false;
    $this->sortDir = (isset($_GET['sortdir'])&&
    !empty($_GET['sortdir'])) ? $_GET['sortdir'] : 'asc';
    $this->limit = (isset($_GET['limit'] &&
    is_numeric($_GET['limit'])) ? $_GET['limit'] : 100;
    }


    function craft_Query(){
    $this->query = "SELECT
    id,
    overview,
    title,
    rate,
    genre,
    seen
    FROM
    log
    ";
    if($this->sortBy !== false){
    $this->query .= "
    ORDER by {$this->sort}
    {$this->sortDir}
    ";
    }
    $this->query .= " LIMIT {$this->limit} ";
    }

    function display_Resutls(){

    $displayDir = ($this->sortDir == 'asc') ? 'desc' : 'asc';

    $html = '

    ';
    foreach($this->thArray as $displayName => $columnName){
    $fontWeight = ($columnName == $this->sortBy) ? 'bold' :
    'normal';
    $html .= '';
    $html .= '
    '.$displayName.'


    ';
    }
    while($obj = mysql_fetch_object($this->result)){
    $html .= '

    '.$obj->title.'
    '.$obj->rate.'
    '.$obj->genre.'
    '.$obj->seen.'

    ';
    }
    $html .= ''
    return print($html);
    }
    }

    class="top">class="black" href="?sort=title">Movie "width:100px;" class="top">class="black" href="?sort=rate">Dice rate "width:100px;" class="top">class="black" href="?sort=genre">Genre "width:180px;" class="top">class="black" href="?sort=seen">Seen