function Build_appt() {
.
.
.
			$output .= ' [' . l(t('delete'), 'cxr/appt/delete/' ) .  $cxr . ']';
				}
				$output .= '</div>';
				$output .= '<div class="cxr_msgt"></div>';
				$output .= '<div class="cxr_msg_body" id="msg_'.$id.'">';
				$output .= $cxr['msg'];
				$output .= '</div>';
				$output .= '<div class="cxr_msgb"></div>';
				$output .= '</div>';
				$output .= '</div>';
			}
			$output .= '</div>';
		}
		$output .= '</div>';
	}
	return $output;
}
// ---
function cxr_appt_delete () {
db_query("DELETE FROM {cxr} WHERE id = %d", $cxr);
drupal_set_message(t('CXR deleted successfully.'));

} 

The build function works, but doesn't call the delete function when tested.

I'm trying to pass the cxr var to a delete function in a drupal module, but the delete function isn't getting called when you click on the link.
Am I not passing to it correctly??

Comments

suro.solutions’s picture

Hi,

I can see some issues in the above code.

  1. $output .= ' [' . l(t('delete'), 'cxr/appt/delete/' ) . $cxr . ']'; this should be like $output .= ' [' . l(t('delete'), 'cxr/appt/delete/' . $cxr['id']) . ']'; $crx is an array you cant send a array in the argument, send the id.
  2. Make sure that you have defined a menu callback for "cxr/appt/delete"
  3. Function should be like
    function cxr_appt_delete () {
    $cxr = arg(3);
    db_query("DELETE FROM {cxr} WHERE id = %d", $cxr);
    drupal_set_message(t('CXR deleted successfully.')); 

Hope this will solve your problem.

Thanks,

Suro

BSmith001’s picture

thanks, I'll add that and see if that works.

What is the arg(3) ?? I've seen it is some of the other code, but didn't get what it was.