mysql - Determine where function was called from in php -
i trying call method this:
<?php getalluser($catid);?>
and there select query in getalluser() method:
function getalluser($query) { $sql = "select * user catid='".$query."'"; }
in page, call same method , pass user id instead of category id so:
<?php getalluser($userid);?>
now, how can identify if there category id or user id in $query, can change in condition base on $query.
add parameter, called from.
options should be:
users categories function getalluser($query, $calledfrom = '') { if ($calledfrom == 'users') { $sql = "select * user catid='".$query."'"; } if ($calledfrom == 'categories') { // sql fetching categories. } }
and call function like:
<?php getalluser($catid, 'users');?> <?php getalluser($catid, 'categories');?>
Comments
Post a Comment