Posts Tagged ‘Searching php’

Metode Searching PHP

Posted: March 18, 2013 in php
Tags:

1. Form & Function

Selanjutnya, setelah pembuatan database selesai, sekarang kita akan membuat Form sederhana untuk fungsi pencarian. kita namakan file ini sebagai “index.php”

<?php
include “config.php”;
$mode = $_REQUEST[‘mode’] ;
$id = $_REQUEST[‘id’];
$search = trim($_POST[‘search’]);
$search_array = explode(” “,$search);
$banyak_kata = (integer)count($search_array);
$searchquery = “select * from article where ” ;
for ( $x = 0; $x<= $banyak_kata; $x++) {
$searchquery .= “isi_artikel like ‘%$search_array[$x]%’”;
if ( $x <  $banyak_kata ) {
$searchquery .= ” AND “;
} (more…)