SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: if Empty sql

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if Empty sql

    Hey all

    I try the following:

    PHP Code:
    if (!empty($_GET['Handelsnaam'])) {
      
    $handelsnaam $_GET['Handelsnaam']
          else
          
    $handelsnaam = % + $_GET['Handelsnaam'] + %

    Unfortunately this does not work.

    Basically I am trying to do the following, if the variable "handelsnaam" is empty it doesn't add wildcards, if it is not empty it does add wildcards...

    That way I can then use that variable in my query and it won't result in every record shown as result if one of my variables is empty (cause empty + wildacards = everything)

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Trying this now but don't know if it's good

    if (!empty($_GET['Handelsnaam'])) {
    $handelsnaam = $_GET['Handelsnaam'];
    } else {
    $handelsnaam = '%' + $_GET['Handelsnaam'] + '%';
    }

  3. #3
    SitePoint Zealot cholmon's Avatar
    Join Date
    Mar 2004
    Location
    SC
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $handelsnaam = isset($_GET['handelsnaam']) ? '%' . $_GET['handelsnaam'] . '%' : '%';
    Drew C King: PHP Developer
    <?= $short_tags++ ?>

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tnx


Bookmarks

Posting Permissions

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