PHP Classes

File: php/search.php

Recommend this page to a friend!
  Classes of Ann   Purp Project   php/search.php   Download  
File: php/search.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Purp Project
Application to manage photo albums
Author: By
Last change: Update of php/search.php
Date: 1 year ago
Size: 1,895 bytes
 

Contents

Class file image Download
<?php
    session_start
();
    require_once
'includes/connect-db.php';

   
$referal = trim(strip_tags(stripcslashes(htmlspecialchars($_POST["referal"]))));
   
//echo $referal;
   
$search = '%'.$referal.'%';
   
$query = "SELECT id, path, title from `pict` WHERE title like '$search'";
   
//$query = "SELECT * FROM `cathegory` WHERE name = '$cath'";
   
$result = mysqli_query($connect, $query)or die('?????? ?'.__LINE__.'<br>?????????? ? ?????????????? ????? ??????????, ??????? ????? ??????.');
   
   
//var_dump($result);
   
if($result){
       
$arrTitles = array();
       
$rows = mysqli_num_rows($result);
       
//echo " ".$rows." ";
       
if( $rows>0){
           
//echo "xui";
           
while ($title = mysqli_fetch_array($result) ) {
               
//print_r($arrTitles);
               
array_push($arrTitles, $title);
            }
            echo
json_encode($arrTitles);
        } else {
            echo
'{ "error":"1" }';
        }
       
//$result->close();
       
}






// $mysqli -> query("SET NAMES 'utf8'") or die ("?????? ?????????? ? ?????!");
// if(!empty($_POST["referal"])){ //????????? ??????

// $referal = trim(strip_tags(stripcslashes(htmlspecialchars($_POST["referal"]))));
// echo $referal;
// $query = "SELECT * from `pict` WHERE 'title' LIKE '%$referal%'";

// $res = mysqli_query($connect, $query)or die('?????? ?'.__LINE__.'<br>?????????? ? ?????????????? ????? ??????????, ??????? ????? ??????.');

// $db_referal = mysqli_fetch_array($res);
   
// while ($row = $db_referal) {
// echo "\n<li>".$row["title"]."</li>"; //$row["name"] - ??? ???? ???????
// }
// }
?>