Code:
//mysql connection
$code = $_POST["coupon"];
$query = "SELECT * FROM mytable";
$result = mysql_query($query);
$found = false;
for ($i = 0;$i < mysql_num_rows($result);$i++) {
$coupon = mysql_result($result,$i,"mycolumn");
if ($code == $coupon) {
$found = true;
}
}
if ($found == true) {
echo "The code ".$code." was found.";
}
mysql_close();
Hopefully you'll know what to edit, but that's basically how you do a mysql search.
There is other ways, using mysql_fetch_assoc, but that can be a little more complicated.
//EDIT: Sorry, I forgot you wanted AJAX. I missed it, but that's a PHP script
Bookmarks