All pastes #991832 Raw Edit

CoW

public text v1 · immutable
#991832 ·published 2008-04-21 12:24 UTC
rendered paste body
function getList()
{
// ORIGNIALE ---|> $query="SELECT * FROM tradetemp pr, tradetype pa WHERE pr.IDtradertype = pa.IDtradertype";
  $query="SELECT * FROM tradetemp pr, tradetype pa WHERE pr.IDtradertype = pa.IDtradertype";
  // Here we check if we have a query parameter :
  if (isset($_POST['query'])){
                $query .= " AND (pr.domaine LIKE '%".$_POST['query']."%' OR pr.url LIKE '%".$_POST['query']."%')";
  }
  //echo $query;
  $result = mysql_query($query);




  $nbrows = mysql_num_rows($result);
  $start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_GET['start']);
  $end = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']);
  $limit = $query." LIMIT ".$start.",".$end;
  $result = mysql_query($limit);
  
  if($nbrows>0){
    while($rec = mysql_fetch_array($result)){
            // render the right date format
      $rec['inscription']=codeDate($rec['inscription']);
      $rec['banni']=codeDate($rec['banni']);
      $arr[] = $rec;
    }
    $jsonresult = JEncode($arr);
    echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
  } else {
    echo '({"total":"0", "results":""})';
  }
}