Adrian Fischer Adrian Fischer - 3 months ago 8
SQL Question

Pass the return from MYSQL into a function

I am trying to pass data returned from a query into the function below. I have put the returned data into the variable $startvalue. I need to pass that variable into the function at the part "initialValue:" but no matter how I try the value is not passed. I have tried putting the variable directly in between the ticks. Add " to either end and fiddled with every conceivable combination I have used in the past but still nothing. I even tried passing the variable to another like this: var initval=$startvalue; and tried to pass that into the function but still nothing. I know the function works because if I enter a numeral manually it does what its supposed to do. Im stumped.

$(function() {

Length: '5',
initialValue: '',
callbackFunctionName: 'processRating',
imageDirectory: 'images/',
inputAttr: 'postID'


You need to begin the PHP parser.

initialValue: '<?php echo $startvalue; ?>',


initialValue: '<?= $startvalue ?>',

To avoid escaping/quote issues, a good trick is to use json_encode when inserting data into Javascript variables:

initialValue: <?= json_encode($startvalue) ?>,