Jump to content

validate true false


jdimino

Recommended Posts

Hi everyone,

I hope someone can help me, I’m not that good with php, but I often find very generous people in this group willing to give me a hand.

I will try my best to explain how the script should work.

I would like to use one of mysql database field ("approve") and have it validated by using using a true or false statement.

When the script is searching mysql database and finds the field approve as false it should give me give me the following message “Registration Pending” and end the script, if no search string found the following message “The Name not Registered you may use this name to Register a new Cultivar” and end script

The field (approve) defaults to false

if it finds the field true, then it should display all data.

please help me

 

 

<?PHP

 

$link = mysql_connect('localhost', 'xxxx_jxxxx', 'jxxxx');

if (!$link) {  die('Could not connect: ' . mysql_error()); }

mysql_select_db('xxxxx');

 

// Fetch total number of records

$result = mysql_query("SELECT COUNT(*) AS recordCount FROM ihsreg");

$row = mysql_fetch_assoc($result);

$recordCount = $row['recordCount'];

 

 

// Perform Search

$results = array();

if(isset($_REQUEST['search'])){

   

    $limit = 20;

    if($_GET['offset']){ $offset = $_GET['offset']; } else { $offset = 0; }

 

    $SQL = "SELECT * FROM ihsreg ";

 

    //$term = strtoupper(addslashes($_REQUEST['search']));

    $term = strtoupper($_REQUEST['search']);

    if(stristr($term,"'") && !stristr($term,"\'")){

        $term = addslashes($term);

    }

 

    if($_REQUEST['radiobutton']){

        switch($_REQUEST['radiobutton']){

        case '1': $SQL.=" WHERE Bloom_Name LIKE \"$term\""; break;

        case '2': $SQL.=" WHERE Pod_Name LIKE \"$term\""; break;

        case '3': $SQL.=" WHERE Pollen_Name LIKE \"$term\""; break;

        case '4': $SQL.=" WHERE Hybridiser LIKE \"$term\""; break;

        case '5': $SQL.=" WHERE Origin LIKE \"$term\""; break;

        case '6': $SQL.=" WHERE Grower LIKE \"$term\""; break;

        case '7': $SQL.=" WHERE Color_Group LIKE \"$term\""; break;

        case '8': $SQL.=" WHERE Bloom_Type LIKE \"$term\""; break;

        case '9': $SQL.=" WHERE Reg_Mini LIKE \"$term\""; break;

        case '10': $SQL.=" WHERE Size_Range LIKE \"$term\""; break;

        case '11': $SQL.=" WHERE Propagation LIKE \"$term\""; break;

        case '12': $SQL.=" WHERE Bloom_Color LIKE \"$term\""; break;

        case '13': $SQL.=" WHERE Bloom_Characteristics LIKE \"$term\""; break;

        case '14': $SQL.=" WHERE Leaf_Characteristics LIKE \"$term\""; break;

        case '15': $SQL.=" WHERE Bush_Characteristics LIKE \"$term\""; break;

        case '24': $SQL.=" WHERE Cross_Made LIKE \"$term\""; break;

        case '25': $SQL.=" WHERE date LIKE \"$term\""; break;

                default: $SQL.=" WHERE Bloom_Name LIKE \"$term\""; break;

        } // switch

    } else {

        // If they didnt' select a radio button... 

        $SQL.=" WHERE Bloom_Name LIKE \"$term\"";

    }

 

    $result = mysql_query($SQL);

    $resultCount = mysql_num_rows($result);

   

    $SQL.= " LIMIT $offset, $limit";

 

    $result = mysql_query($SQL);

   

    if($resultCount > 0){

        while($row = mysql_fetch_assoc($result)){

            $results[$row['id']] = $row;

        } // while

    } // if there are results

} // if user performed a search

?> 

     

 

 

Link to comment
Share on other sites

  • 7 months later...

<?php
$sql = "SELECT approve FROM mytable WHERE stringfield='$searchstring'";
$result = mysl_query($sql);
if(mysql_num_rows($result)>0)
{
if(mysql_result($result,0,"approve")=="false")   //I assume that the stringfield holds distinct values
echo "Registration Pending";
else
echo "Validated"
}
else
{
echo "The Name not Registered you may use this name to Register a new Cultivar";
}
?>

 

Use that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.