I have this while loop in php:
<?php while($percentSKU = sqlsrv_fetch_array($resultSKU, SQLSRV_FETCH_ASSOC)) : ?>
<p><?php echo $percentSKU['PercentageSales']; ?>%</p>
<?php endwhile; ?>
<?php echo $percentSKU['PercentageSales']; ?>
If it is returning a string you can convert it to an array and access it via its index. To convert a string to an array you can use the explode function.
for ex :
$string = '.00%, .00%, .00%, .00%, 26.22%, .00%, 3.96%, 1.49%, 5.23%, 20.88%, 42.22%, .00%'; $result = explode(',' $string); $finalvalue = $result;
Note : The $result will return the first value of the string, you will have to set the index which you require.