title: Comparing strings returned from a mySql query
body: <p>I am querying a large number of codes from my database, and need to have some validation before a user can input another code in to the database. </p>
  
  <p>An example code would be this:</p>
  
  <p>TD-BR-010212-xxxxxxxx</p>
  
  <p>Where TD represents a promotion, BR represents a place, the numbers represent a date, and the rest are random.</p>
  
  <p>My problem is that before the code is entered into the DB, I want to check to see if the date and place for that code already exists, as they should not be allwed to enter a code from the same place and date.</p>
  
  <p>I assume it would be something within a loop as I already have:</p>
  
  <pre><code>$location_part_of_td = $code[2].$code[3];
  $date_part_of_td = $code[4].$code[5].$code[6].$code[7].$code[8].$code[9];
  
  $trade_day_result = mysql_query('SELECT * from wp_scloyalty WHERE promotion_type = trade-day') or die(mysql_error());  // Pulls all trade day codes from the database and checks the date part of the code. 
  
  // the date part exists with the same area part, user cant redeem.
  while($info = mysql_fetch_array( $trade_day_result )) 
  { 
  
       $code = $info["product"];
  
  } 
  </code></pre>
  
  <p>But Im just not sure about the best way to check the strings..</p>