JQuery and PHP

Sorry, I have to ask this question again but in a different way:  
How do you place a PHP variable into a JQuey Script?

See currentAmount:  below
<?php
function progess() {
$goal = "23";
}
?>

<?php progrss(); ?>

<?php progressBar(); ?>
<script type="text/javascript">
$(document).ready(function(){
    $('#sample_goal').goalProgress({
        goalAmount: <?php echo '1000'; ?>,
        currentAmount: <?php echo $goal; ?>,
        textBefore: 'Amount Raised $',
        textAfter: ''
    });
});
</script>

Open in new window


What am I doing wrong?
LVL 7
rgranlundAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Marco GasiConnect With a Mentor FreelancerCommented:
Use this:
<?php
function progess() {
    return "23";
}
$goal = progress();
?>

Open in new window

0
 
Marco GasiFreelancerCommented:
The problem was that your variable $goal was visible only within the function: about variable scope
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.