Hi there.
I have a PHP Function like so:
[php] <?php function JomSocial_field($fieldcode) {
$database=& JFactory::getDBO();
$user =& JFactory::getUser();
$userId = $user->get( ‘id’ );
$sql = “SELECT (id) FROM #__community_fields WHERE fieldcode= ‘$fieldcode’”;
$database->setQuery( $sql );
$fieldID = $database->loadResult();
$sql = “SELECT (value) FROM #__community_fields_values WHERE field_id= {$fieldID} && user_id= {$userId}”;
$database->setQuery( $sql );
echo $database->loadResult();
}
?>[/php]
I can then insert the results into form inputs like so: <input type="hidden" id="enrolment_year" name="enrolment_year" value="<?php JomSocial_field("enrolment_year"); ?>" />
However, I now want to use the result in a variable like so
[php] <?php $filename1 = “folder/”.print(JomSocial_field(“enrolment_year”))."/file.zip";[/php]
but it doesn’t work…it just actually prints the result as text on the page. The echo command doesn’t work either. If it were an item that has been posted, I could get it using the $_POST[“enrolment_year”], but the trouble is, I want to get the value on first page load, not after a post.
Can anyone help me please?