I am using
echo instead of
return becuase
return will simply not output anything. I did replace my function with your more simplified version,
Jcart. I didn't know that you could simply output the total rows without first assigning it to a variable. Here is my function now:
.
Code: Select all
function totalComments($val) {
$econtrolt411 = mysql_pconnect("foo", "foo", "foo") or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db("ect411", $econtrolt411);
$query_totalComLIST = "SELECT * FROM con_confessionscomm WHERE conID=$val";
$totalComLIST = mysql_query($query_totalComLIST, $econtrolt411) or die(mysql_error());
echo mysql_num_rows($totalComLIST);
}
Here is the issue now, when I set a condition using the function, it echos the function out and does not use it in the condition.
Code: Select all
if (totalComments($row_conDETAILS['conID'])>0){ echo "foo"; }
This might help. In ASP, I can call a function like this and have it replace the function with the result. And the function does not have to echo anything. The trick is have the function name the same as the variable you assign the function result to. So in php it would look like this:
Code: Select all
function totalComments($val) {
$econtrolt411 = mysql_pconnect("foo", "foo", "foo") or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db("ect411", $econtrolt411);
$query_totalComLIST = "SELECT * FROM con_confessionscomm WHERE conID=$val";
$totalComLIST = mysql_query($query_totalComLIST, $econtrolt411) or die(mysql_error());
$totalComments = mysql_num_rows($totalComLIST);
}
But that does not work because the fucntion is not a variable name. Is there a way to do this? That may do the trick for me.