PHP Classes

File: teste.php

Recommend this page to a friend!
  Classes of Carlson A. Soares   Search by Relevance   teste.php   Download  
File: teste.php
Role: Example script
Content type: text/plain
Description: Script of exemple showing the class function
Class: Search by Relevance
Sort arrays or MySQL searches by relevance
Author: By
Last change:
Date: 13 years ago
Size: 2,307 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title></title>
</head>
<body>

<?php
   
    $host
= "localhost";
   
$user = "user";
   
$password = "user$";
   
$database = "teste";
   
   
$conn = mysql_connect($host, $user, $password) or die ('Erro ao conectar na base de dados');
           
   
mysql_query("SET NAMES 'utf8'");
   
mysql_query('SET character_set_connection=utf8');
   
mysql_query('SET character_set_client=utf8');
   
mysql_query('SET character_set_results=utf8');
           
   
mysql_select_db($database);
   
   
    echo
'MYSQL RESULTSET SEARCH TEST<br>5 most relevant results<br /><br />';
    require_once(
'search_mysql.php');
   
   
$query = mysql_query( 'select * from cidades where estado = 26 order by 1', $conn);
   
   
$s = new Search_Mysql();
   
    echo
'Searching for xão pauLO - Case Sensitive in cities of São Paulo<pre>';
   
print_r( $s->doSearch('xão pauLO',$query, 'nome',5,2,true) );
   
    unset(
$query );
   
$query = mysql_query( 'select * from cidades where estado = 26 order by 1', $conn);
   
    echo
'</pre><br><br>Procurando por xão pauLO - No Case Sensitive in cities of São Paulo<pre>';
   
print_r( $s->doSearch('xão pauLO',$query, 'nome',5,2,false) );
    echo
'</pre><br /><br /><br /><br />';
   
    unset(
$s );
    unset(
$query );
   
    echo
'TESTING ARRAY SEARCH CLASS<br />5 most relevant results<br /><br />';
   
   
$query = mysql_query( 'select nome from cidades where estado = 26 order by 1', $conn);
   
$list = array();
   
    while(
$row = mysql_fetch_assoc( $query ) ){
       
$list[] = $row['nome'];
    }
   
    require_once(
'search.php');
   
   
$s = new Search();
   
    echo
'Searching for xão pauLO - Case Sensitive in cities of São Paulo<pre>';
   
print_r( $s->doSearch('xão pauLO',$list,5,2,true) );
   
    echo
'</pre><br><br>Searching for xão pauLO - No Case Sensitive in cities of São Paulo<pre>';
   
print_r( $s->doSearch('xão pauLO',$list,5,2,false) );
   
    echo
'</pre>';
   
?>

   
</body>
</html>