Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP How to check if MySQL result contains value
  2. $getfreq = mysql_query("SELECT wp_term_relationships.term_taxonomy_id FROM wp_term_relationships WHERE wp_term_relationships.object_id = '1737'");
  3.        
  4. if (in_array(569,$getfreq,TRUE) {
  5.     echo "Success!";
  6. } else if (in_array(654,$getfreq,TRUE) {
  7.     echo "Not good";
  8. } else {
  9.     echo "Failure";
  10. }
  11.        
  12. print_r($getfreq);
  13.        
  14. $res = mysql_fetch_array($getfreq);
  15.        
  16. if (in_array(569,$res,TRUE) {....
  17.        
  18. while ( false !== ($row = mysql_fetch_assoc($getfreq))) {
  19.    // make your comparison for each row  
  20. }
  21.        
  22. while ($row = mysql_fetch_assoc($getfreq)) {
  23.     if ($row[term_taxonomy_id] == 345) {
  24.         echo "WORKS!";
  25.     }
  26. }