Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    searching only 3 letters only

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

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    You can start by placing your code within code tags.

  • #3
    New Coder
    Join Date
    May 2008
    Posts
    80
    Thanks
    3
    Thanked 3 Times in 3 Posts
    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??
    Code:
    $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.

  • #4
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh

    How??? can you guys typed it a sample? tnx and tnx

  • #5
    New Coder
    Join Date
    May 2008
    Posts
    80
    Thanks
    3
    Thanked 3 Times in 3 Posts
    I'm afraid I can't because i don't know what this
    Code:
    $_GET['q']
    returns

  • #6
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh it is my javascript in autosuggest seafrch

    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

  • #7
    New Coder
    Join Date
    May 2008
    Posts
    80
    Thanks
    3
    Thanked 3 Times in 3 Posts
    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!!??


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •