0

I created a variable to check and echo out results for a particular patient:

<?php 
$ex = sql::value("select 1 email from " . event_table('email_rules') . " where patient_id={$patient->hex}");
if ($ex == 1) {echo "Records";} else {echo "None";} 
?>

My html input is simple, cbox is checkbox:

<tr><td>Email</td><td><?php cbox('email'); ?></td></tr>

If someone checks the email box but there is no email in sql than i need to throw an alert saying there is no email associated.

I'm assuming I could use jquery or javascript to get this accomplished in a clean and concise manner. I hope I'm fairly clear on what i'm trying to accomplish. Help would be greatly appreciated. Thank you.

Head
  • 548
  • 7
  • 26
  • you want to validate the email right? have a look at this http://stackoverflow.com/questions/2855865/jquery-regex-validation-of-e-mail-address – btevfik Mar 18 '13 at 23:03
  • I don't necessarily need to validate the email, i just need to check sql upon click to see if there is any email associated with the account. – Head Mar 18 '13 at 23:04
  • check for null then, http://php.net/manual/en/function.is-null.php – btevfik Mar 18 '13 at 23:06
  • select the email for that user and use the is_null function for checking. should work i think – btevfik Mar 18 '13 at 23:07
  • 1
    The simplest method is to check on the server when the page loads and set the checkbox's attribute disabled to disabled. This will save on the round trip. If you want to check it after the page loads, you can put a click event on the checkbox that runs an ajax request using jQuery, set async to false (forcing the ajax request to finish) and then if no email show popup and return false to keep the check box from being checked. – Kalpers Mar 19 '13 at 00:10

0 Answers0