View Full Version : searching only 3 letters only

03-24-2010, 02:48 AM
include ('config.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);

echo '<ul>';
while ($row = mysql_fetch_array($getRecord)) {?>
<a href="print.php?tinID=<? echo $row['strEmployeeTIN']; ?>" title="VIEW">
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>

<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:

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

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.

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

03-25-2010, 06:23 AM
I'm afraid I can't because i don't know what this

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");
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;
function autosuggestReply() {
if(http.readyState == 3){
var response = http.responseText;
e = document.getElementById('results');
} else {

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

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!!??