jdimino Posted April 1, 2009 Share Posted April 1, 2009 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 ?> Quote Link to comment Share on other sites More sharing options...
felixtgomezjr Posted November 28, 2009 Share Posted November 28, 2009 <?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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.