Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 33
  1. #21

    sorry sa double post. hinay ako net

  2. #22
    Quote Originally Posted by xiao_xiao View Post
    ani mn tingale
    PHP Code:
    <?php
    $keyword 
    $_POST['searchword'];

    $query1 "SELECT * FROM table1 WHERE name LIKE '%".$keyword."%'";
    $query2 "SELECT * FROM table2 WHERE name LIKE '%".$keyword."%'";
    $query3 "SELECT * FROM table3 WHERE name LIKE '%".$keyword."%'";

    $result1 mysql_query($query1) or die(mysql_error());
    $result2 mysql_query($query2) or die(mysql_error());
    $result3 mysql_query($query2) or die(mysql_error());

    $num_rows1 mysql_num_rows($result1);
    $num_rows2 mysql_num_rows($result2);

    if (
    $num_rows1 == 0)
    {
        
    $finalResult $result2;
    //end if

    elseif ($num_rows2 == 0)
    {
        
    $finalResult $result3;    
    //end elseif

    else
    {
        
    $finalResult $result1;
    }

    while (
    $row mysql_fetch_assoc($finalResult))
    {
        
    $name $row['name'];
        echo 
    $name.'\n';
    //end while
    ?>
    ay bai, ako na gi-try ganina pero i think dili pwede kay d ba ang mysql_num_rows($result1) kay either TRUE OR FALSE ra man? so duha ra.

  3. #23
    0 or 1 works with mysql i think. Using odbc-sqlserver here and it works.

    OR, use

    if ($num_rows1) {
    }

  4. #24
    dili mn boolean ang e-return sa num_rows. kanang num_rows kay kung pila ka set of data... like for example sa table1, if you have 3 names... "john", "joe", "jerz"... then it will return 3... so kung walay data sa table1, it will return 0.

  5. #25
    ay akong pasabot sa TRUE of FALSE bai kay ang condition ba bai, i-equate lang nimo og 0 OR 1 lang.

  6. #26
    Quote Originally Posted by personalmgt View Post
    0 or 1 works with mysql i think. Using odbc-sqlserver here and it works.

    OR, use

    if ($num_rows1) {
    }
    medyo sakto pud ning imoha bai, pero if sample mag-search ka ug "Jose", ang iyang i-return bai kay tanang names nga naay "jose" like: "jose","joselito", etc. mura ba siya ug walay restrictions ba.

  7. #27
    sharing knowledge is important... Of course, everybody has their own techniques. I like to share too...read this..... if you like

    LINK: MySQL :: MySQL 5.0 Reference Manual :: 12.2.8.3 UNION Syntax

    I let MySQL do the work sometimes. hehehehe

    Last edited by dodie; 02-25-2010 at 10:41 AM.

  8. #28
    Quote Originally Posted by xiao_xiao View Post
    dili mn boolean ang e-return sa num_rows. kanang num_rows kay kung pila ka set of data... like for example sa table1, if you have 3 names... "john", "joe", "jerz"... then it will return 3... so kung walay data sa table1, it will return 0.
    akong i-clarify... for example nag search ka ug "john"... 1 ra ang e-return sa num_rows... kung "jo" imong e-search kay 2 ang e-return kay naa may "jo" ang "john" ug "joe"

    -----------

    as much as possible mas nice kung single query ra jud... try ng link nga gi-post ni dodie.

  9. #29
    ok ra bai, i-remove ra d i ang percent (%) symbol para dili ma-preempt ang system nga mo-return diretso ug bisan unsa. pareha sa imong sample nga if "jo" ang i-search kay i-return niya kay "john ug "joe". mas nindot man gud na nga if "jo" ang input, dapat "jo" ra pud iyang pangitaon, and if "%jo%" ang input, anha pa siya mo-return ug all names with "jo" within them.

    Another thing bai, akong gigamit d i kay "mysql_execute_now()" instead of "mysql_query()"

  10. #30
    in my case bai, no need na mag UNION kay lain2x man ug sulod ang kada table. but if naay uban nga pare-pareha ug sulod ang tables, then that's the time maybe to use UNION.

  11.    Advertisement

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

 
  1. How to remove a site from Google search results.
    By the_wandering_slasher in forum Networking & Internet
    Replies: 5
    Last Post: 02-05-2011, 04:11 PM
  2. How to convert files recorded in mini DV digicam to DVD?
    By sikput in forum Computer Hardware
    Replies: 8
    Last Post: 08-29-2006, 01:01 PM
  3. How to save video streaming from youtube.com
    By koto in forum Software & Games (Old)
    Replies: 29
    Last Post: 03-26-2006, 10:54 PM
  4. Replies: 0
    Last Post: 01-28-2006, 01:48 PM
  5. How to make a connection from my 6600 to computer?
    By rey04 in forum Gizmos & Gadgets (Old)
    Replies: 7
    Last Post: 12-03-2005, 05:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top