Results 1 to 13 of 13

Thread: check if query has something

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    check if query has something

    PHP Code:
    SELECT FROM reviews WHERE instr(gamename'$search'
    is that right?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    this is how i do it:

    mysql_query("SELECT * FROM book ORDER BY title ASC",$db);

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  3. #3

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    its like a mini search thingy, i want it search the reviews for $search and return the results
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  4. #4

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    any suggestions?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  5. #5

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    oh ok

    that will check if that has $search in it right?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  6. #6
    scoutt
    Guest
    correct, it will check to see if what the user entered and if it is in the database, so if

    $search = table

    then once it goes through it's search it then will fine any game that has table in it. that is what the % means. it can have anything before it or after it but it has to contain table.

  7. #7

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    it wont work. like it wont find anything
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  8. #8
    scoutt
    Guest
    what's the cod eyou have now?

  9. #9

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    PHP Code:
    $sql="SELECT * FROM reviews WHERE (gamename LIKE '%$search%') OR (review LIKE '%$search%') OR (name LIKE '%$search%') OR (describ LIKE '%$search%')";

                    
    $result mysql_query($sql);
                    echo 
    "<UL>\n";
                    while (
    $row mysql_fetch_array($result)) {
                        
    printf("<li><a href=\"viewreview.php?id=%s&system=%s\">%s</a> - by <a href=\"../forums/profile.php?mode=viewprofile&u=%s\">%s</a> - %s</li>"$row['id'], $row['system'], $row['gamename'], $row['id'], $row['name'], $row['describ']);
                    }
                    echo 
    "</UL><BR>\n"
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  10. #10
    scoutt
    Guest
    like this.

    PHP Code:
    $sql="SELECT * FROM reviews WHERE (gamename LIKE '%$search%' OR review LIKE '%$search%' OR name LIKE '%$search%' OR describ LIKE '%$search%')"

  11. #11

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    still wont work, no errors are returned
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  12. #12
    scoutt
    Guest
    try this and see if the select statement is ok on the ouput. also it will give an error if the result is wrong. also make sure all the categories are actually in the reviews table. Also what is the form coding that the search is coming from?
    PHP Code:
    $sql="SELECT * FROM reviews WHERE (gamename LIKE '%$search%' OR review LIKE '%$search%' OR name LIKE '%$search%' OR describ LIKE '%$search%')";
                  echo 
    $sql;

                    
    $result mysql_query($sql);
                     if (!
    $result)
                    {echo 
    mysql_error($result)}

                    echo 
    "<UL>\n";
                    while (
    $row mysql_fetch_array($result)) {
                        
    printf("<li><a href=\"viewreview.php?id=%s&system=%s\">%s</a> - by <a href=\"../forums/profile.php?mode=viewprofile&u=%s\">%s</a> - %s</li>"$row['id'], $row['system'], $row['gamename'], $row['id'], $row['name'], $row['describ']);
                    }
                    echo 
    "</UL><BR>\n"

  13. #13

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    alright i got it, thanks

    i noticed it wasnt showing the SQL statement, this was the prob:

    PHP Code:
    if($submit){ //check if submitted
    ...

    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

Posting Permissions

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



Click Here to Expand Forum to Full Width