Вы должны использовать уникальные ключи для вашего обоих поисковых запросов {searchVal2: searchTxt}
или js
использовать их в условиях поиска php соответственно
Попробуйте изменить свой код php
и php
код, как показано ниже:
JS:
function searchq() {
var searchTxt = $("input[name='search1']").val();
$.post("testsearch.php", {searchVal: searchTxt}, function(output) {
$("#output") .html(output);
});
}
function searchw() {
var searchTxt = $("input[name='search2']").val();
$.post("testsearch.php", {searchVal2: searchTxt}, function(output) {
$("#output") .html(output);
});
}
Php:
mysql_connect ("localhost","xxxx","xxxx") or die ("Tilkoblingsfeil");
mysql_select_db ("xxxx") or die("Finner ikke database");
$output = '';
if(isset($_POST['searchVal'])) {
$searchq = $_POST['searchVal'];
$searchq = preg_replace ("#^0-9#"," ",$searchq);
$query = mysql_query("SELECT * FROM ds_OrderItem WHERE idProduct LIKE '%$searchq%' LIMIT 100") or die("Klarte ikke soke!");
$count = mysql_num_rows ($query);
if($count == 0){
$output = 'Ingen produktID med disse verdiene';
}else{
$output .='<table border="1" cellpadding="5" cellspacing="1" width="50%" bordercolor="grey"><tr><th>ProduktID</th><th>Ordrenummer</th><th>Beskrivelse</th><th>Antall</th>';
while($row = mysql_fetch_array($query)) {
$output .= '<tr><td>'.$row['idProduct'].'</td><td>'.$row['idOrder'].'</td><td>'.$row['title'].'</td><td>'.$row['qty'].'</td></tr>';
}
$output .='</table>';
if($_POST['searchVal'] == NULL) {
$output = "";
}
}
exit($output);
}
if(isset($_POST['searchVal2'])) {
$searchw = $_POST['searchVal2'];
$searchw = preg_replace ("#^0-9a-z#i"," ",$searchw);
$query = mysql_query("SELECT * FROM ds_OrderItem WHERE title LIKE '%$searchw%' LIMIT 100") or die("Klarte ikke soke!");
$count = mysql_num_rows ($query);
if($count == 0){
$output = 'Ingen TECDOC artikler med disse verdiene';
}else{
$output .='<table border="1" cellpadding="5" cellspacing="1" width="50%" bordercolor="grey"><tr><th>ProduktID</th><th>Ordrenummer</th><th>Beskrivelse</th><th>Antall</th>';
while($row = mysql_fetch_array($query)) {
$output .= '<tr><td>'.$row['idProduct'].'</td><td>'.$row['idOrder'].'</td><td>'.$row['title'].'</td><td>'.$row['qty'].'</td></tr>';
}
$output .='</table>';
if($_POST['searchVal'] == NULL) {
$output = "";
}
}
exit($output);
}
?>