hi i have written the following function to get a value from my database:
function getSlCreatedate($sid) {
$query1 = "SELECT Sub_type FROM `Sub` where `Sub_id` = $sid";
$queryresult1 = mysql_query($query1);
$row1 = mysql_fetch_assoc($queryresult1);
$type1 = $row1['created_ts'];
if($type1 == 'SL') {
$query2 = "SELECT Sub_attr_value FROM `Sub_attr_list` WHERE `Sub_attr_type_id` = 20 AND `Sub_id` = $sid";
$queryresult2 = mysql_query($query2);
$row2 = mysql_fetch_assoc($queryresult2);
$type2 = $row2['Sub_attr_value'];
if($type2 == " "){
$query3 = "SELECT Created_ts FROM `Sub` WHERE `Sub_id`= $sid";
$queryresult3 = mysql_query($query3);
$row3 = mysql_fetch_assoc($queryresult3);
return $row3['Created_ts'];
}
else {
return $type2['Sub_attr_value'];
}
}
else
return 0;
}
what's the condition is I need to first check the Sub_type in Database for the given "sid" value and if returns "SL" as result then I need to get the "Sub_attr_value" from "Sub_attr_list" table, if this value returns empty rows or value NULL, then I've to return the "Created_ts" value for that sid to the page, Here all the queries are working fine when i exectued in my PHP MyAdmin seperately, can anyone guide me to complete this, I'm not able to get the value from here to the page.
The function call in my page is as follows:
$sldate = db_func::getSlCreatedate($sub_list[$i]['Sub_id']);
fortunately it is not showing any errors as well not showing the expected result.