Page 1 of 1
How to check empty columns in a table
Posted: Sat Jul 05, 2003 8:18 am
by minds_gifts
Hello everybody,
How can i do this one??
If i press a button, i have to check if certain columns(fields) in a table are empty.If they are empty, i want to send an e-mail to the e-mail address which is already in this table.If there are no empty columns, then i want to do some calculation using another table.
Could somebody please tell me how should i do.
Many many thanks
Posted: Sat Jul 05, 2003 8:50 am
by Drachlen
EDIT: for the button part, i would make a link that would goto a page that did this in an if statement.
Code: Select all
<?php
$link = mysql_connect("localhost", "***", "***")
or die("Could not connect");
mysql_select_db("your_database", $link) or die("Could not select database");
$query = MYSQL_QUERY("SELECT * FROM table WHERE field=''");
while ($fetch=mysql_fetch_array($query)) {
mail($email, "Your Subjet Here", "This email was sent for a reason, but I don't know why!");
}
?>
Now, all you need to modify is your connection username and password, where you're selecting from, and what field you want to check that is blank. i just tested this, and it works fine for me. Reply if you have troubles!
Posted: Sat Jul 05, 2003 9:24 am
by minds_gifts
Thanks drachlen.How can i modify further my query if i want to check for certain columns in a table??For example, if i have a table with columns(first_name, last_name, email, city, zipcode and so on.....)
I want to check if my columns(zipcode, city are empty).
thanks
Posted: Sat Jul 05, 2003 10:36 am
by Drachlen
Code: Select all
<?php
WHERE zipcode='' AND city=''
?>
in place of: