...

View Full Version : searching only 3 letters only



dhie20
03-24-2010, 02:48 AM
<?php
include ('config.php');
?>
<?php
$searchq = strip_tags($_GET['q']);
$getRecord_sql = 'SELECT * FROM tblemployee WHERE strEmployeeTIN LIKE "'.$searchq.'" OR strLastName LIKE "&'.$searchq.'" OR strFirstName LIKE "'.$searchq.'" OR strMiddleName LIKE "'.$searchq.'" OR strEmpStatus LIKE "%'.$searchq.'" OR dtmDateOfBirth LIKE "'.$searchq.'" ';
$getRecord = mysql_query($getRecord_sql);
if(strlen($searchq)>0){

echo '<ul>';
while ($row = mysql_fetch_array($getRecord)) {?>
<li>
<a href="print.php?tinID=<? echo $row['strEmployeeTIN']; ?>" title="VIEW">
<?php
echo '<br><font size=5>'.$row['strEmployeeTIN'].'</font>';
echo '<br><strong><i><font color="#FFF">'.ucfirst($row['strLastName']). ', ' .ucfirst($row['strFirstName']). ' ' .ucfirst($row['strMiddleName']).'</font></i></strong><br>'; ?>

<small>Employee Status: <?php echo $row['strEmpStatus']; ?></small><br>
<small>Last Promotion: <?php echo $row['dtmLastPromotion']; ?></small><br>
<small>Contact No: <?php echo $row['strContactNum']; ?> or <?php echo $row['strCellNum']; ?></small>
</li>
<br>

<a href="edit/editpersonaldata.php?tinID=<? echo $row['strEmployeeTIN']; ?>"><img src="images/edit.png" alt="EDIT" title="EDIT"/></a>
<!--<a href="view.php?tinID=<? echo $row['strEmployeeTIN']; ?>"><img src="images/view.png" alt="VIEW" title="VIEW"/></a>-->
<a href="print.php?tinID=<? echo $row['strEmployeeTIN']; ?>"><img src="images/pdf.png" alt="PDF" title="PDF"/></a>
<!--<a href="print.php?tinID=<? echo $row['strEmployeeTIN']; ?>"><img src="images/print.png" alt="PRINT" title="PRINT"/></a> -->

<?php } echo '</ul>'; } ?>




---------------------------




How Can I add by searching only 3 strings or letter?
pls help

my search only complete name and last name


i need to change it by 3 strings search only thanx:thumbsup:

MattF
03-24-2010, 11:47 AM
You can start by placing your code within code tags.

tfit
03-24-2010, 12:46 PM
Two questions;
what about duplicates, if you take some paper and fill out some values you will see you get duplicates. Second, is this a long string??
$searchq = strip_tags($_GET['q']);
Anway, my solution would be to do a substr($str,0,3) and place the whole query in a heredoc.

dhie20
03-25-2010, 05:52 AM
How??? can you guys typed it a sample? tnx and tnx:confused::thumbsup::D

tfit
03-25-2010, 06:23 AM
I'm afraid I can't because i don't know what this
$_GET['q']returns

dhie20
03-25-2010, 09:10 AM
here is where ii goes:

/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* -------------------------- */
/* SEARCH */
/* -------------------------- */
function autosuggest() {
q = document.getElementById('search-q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'inc/searchchk.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggestReply() {
if(http.readyState == 3){
var response = http.responseText;
e = document.getElementById('results');
if(response!=""){
e.innerHTML=response;
e.style.display="block";
} else {
e.style.display="none";
}
}
}

-----------
so how cud i limit it to 3 words search only:thumbsup::confused:

tfit
03-26-2010, 09:09 AM
To make the page non-cacheable I would do it server-side. You make it harder for yourself to strip out that part. If I understand you correctly you return a long string to the server in $_GET and want to limit your query with 3 words from that string? Of course you now there is a size limit of use get. Are you randomizing the words? Otherwise you can simply hardcode them!!??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum