Results 1 to 5 of 5

Thread: How to add a filter

  1. #1
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to add a filter

    Hi everyone
    I would like to add a filter that will check a name in the database, If name does not exist then it should add [Not Registered] to the name
    I tried to write the code in blue but I get an error, can someone help


    PHP Code:
    mysql_numrows($result); 
     if(
    $num 0){ 
        
    $name_exist "<font size=5>$BloomName is a Registered Cultivar. Please Rename your Cultivar.</font>"
        echo 
    $name_exist;
        exit;
     } else {
        
    $name_ok "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";
        

     [
    COLOR="Blue"]  $pod_reg "$PodName"
        exit;
     } else
        
    $pod_reg "$PodName+[Not Registered]";

     }[/
    COLOR

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Well, to do what you want to do (I think) edit the code like this:

    PHP Code:
    else
       
    $pod_reg $PodName ' [Not Registered]'
    The "." concatenates the string so it will out the variable and then the sceond part, i.e:

    $PodName = 'Schmoopy';

    This will output : Schmoopy [Not Registered]

    Hope this helps.

  3. #3
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi
    I get the following error, where is it?

    Parse error: syntax error, unexpected $end in /home1/internb7/public_html/icra/form2.php on line 1555

    PHP Code:
    if($num 0){ 
        
    $name_exist "<font size=5>$BloomName is a Registered Cultivar. Please Rename your Cultivar.</font>"
        echo 
    $name_exist;
        exit;
     } else {
        
    $name_ok "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";
    if(
    $num 0){
       
    $pod_exist "$PodName"
        exit;
     } else {
       
    $pod_reg $PodName ' [Not Registered]';


  4. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    You didn't end one of your conditional statements:

    PHP Code:
     } else {
        
    $name_ok "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";

    Change your code to the above, or you can take out the curly braces all together, as you don't need them for a one line command.

  5. #5
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi
    Thanks for your help, now it works, but I realize that $podreg is not in the database therefore I only get [Not Registered] echo without the name, can I add a code that gets the name from the PodName text field in the form? if so how


    PHP Code:
    if($num 0){ 
        
    $name_exist "<font size=5>$BloomName is a Registered Cultivar. Please Rename your Cultivar.</font>"
        echo 
    $name_exist;
        exit;
     } else {
        
    $name_ok "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";}

    if(
    $num 0){ 
        
    $pod_exist "$PodName"

     } else {
        
    $podreg $Pod_Name ' [Not Registered]';} 

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
  •