Am un script:
Cod: Selectaţi tot
// Credentials
$dbhost = "localhost";
$dbname = "";
$dbuser = "";
$dbpass = "";
// Connection
global $tutorial_db;
$tutorial_db = new mysqli();
$tutorial_db->connect($dbhost, $dbuser, $dbpass, $dbname);
$tutorial_db->set_charset("utf8");
// Check Connection
if ($tutorial_db->connect_errno) {
printf("Connect failed: %s\n", $tutorial_db->connect_error);
exit();
}
/************************************************
Search linkality
************************************************/
// Define Output HTML Formating
$html = '';
$html .= '<li class="result">';
$html .= '<a target="_blank" href="urlString">';
$html .= '<h3>nameString</h3>';
$html .= '<h4>linkString</h4>';
$html .= '<h3>pret</h3>';
//$html .= '<h3>moneda</h3>';
$html .= '</a>';
$html .= '</li>';
// Get Search
$search_string = preg_replace("/[^A-Za-z0-9]/", " ", $_POST['query']);
$search_string = $tutorial_db->real_escape_string($search_string);
// Check Length More Than One Character
if (strlen($search_string) >= 1 && $search_string !== ' ') {
// Build Query
$query = 'SELECT * FROM produse WHERE denumire LIKE "%'.$search_string.'%"';
// Do Search
$result = $tutorial_db->query($query);
while($results = $result->fetch_array()) {
$result_array[] = $results;
}
// Check If We Have Results
if (isset($result_array)) {
foreach ($result_array as $result) {
// Format Output Strings And Hightlight Matches
$display_link = $result['link'];
$display_pret = 'Pret: '.$result['pret'].' '.$result['moneda'];
//$display_moneda = ' '.$result['moneda'];
$display_name = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['denumire']);
$display_url = $result['link'];
// Insert Name
$output = str_replace('nameString', $display_name, $html);
// Insert link
$output = str_replace('linkString', $display_link, $output);
// Insert pret
$output = str_replace('pret', $display_pret, $output);
// Insert moneda
//$output = str_replace('moneda', $display_moneda, $output);
// Insert URL
$output = str_replace('urlString', $display_url, $output);
// Output
echo($output);
}
}else{
// Format No Results Output
$output = str_replace('urlString', 'index.php', $html);
$output = str_replace('nameString', '<b>Nu s-a gasit produsul cautat. Scrie alte cuvinte</b>', $output);
//$output = str_replace('linkString', 'Incearca ', $output);
// Output
echo($output);
}
}
Acest script merge dar nu cum as dori eu.
De exemplu am produsele acestea:
Cod: Selectaţi tot
MDR1425-Manseta tensiometru MORETTI cu 2 tuburi, pentru adulti obezi.
MDR125-Manseta tensiometru MORETTI cu 2 tuburi, cosciala (picior), cu scai
MDR1436-Manseta tensiometru MORETTI cu un tub, pentru adulti, cu carlig
mdr 2 moretti sa imi afiseze aceste produse.
Scriptul pe care il am eu trebuie sa scriu in ordinea in care sunt si daca scriu alt cuvant care este in titlul produsului imi zice ca nu este podusul respectiv. cum as putea sa modific sau unde as putea gasi un script care ar face asa ceva. Multumesc aticipat.
Cu stima Trif