Advertisement
bobsona

fixed php

Jul 31st, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.  header('Content-Type: text/html; charset=utf-8');
  3. if ( !isset($_REQUEST['term']) )
  4.     exit;
  5.  
  6. include 'includes/config.php';
  7. $rs = mysql_query('SELECT * FROM `news` WHERE `title` LIKE "%'. mysql_real_escape_string($_REQUEST['term']) .'%" ORDER BY id DESC LIMIT 0 , 10');
  8. $data = array();
  9. if ( $rs && mysql_num_rows($rs) )
  10. {
  11.     while( $row = mysql_fetch_array($rs) )
  12.     {
  13.         $data[] = array(
  14.             'label' => htmlspecialchars_decode($row['title']),
  15.             'value' => htmlspecialchars_decode($row['title'])
  16.         );
  17.     }
  18. }
  19. echo json_encode($data);
  20. flush();
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement