# Variable to get all the results followed by commas. PHP/MySQL

**URL:** <https://forum.kirupa.com/t/variable-to-get-all-the-results-followed-by-commas-php-mysql/152268>\
**Category:** programming\
**Created:** [June 22, 2005, 2:54pm UTC](https://forum.kirupa.com/t/variable-to-get-all-the-results-followed-by-commas-php-mysql/152268 "2005-06-22T14:54:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [June 22, 2005, 2:54pm UTC](https://forum.kirupa.com/t/variable-to-get-all-the-results-followed-by-commas-php-mysql/152268/1 "2005-06-22T14:54:08Z")

</div>

I do a MySQL query and I get like 3 different results for $price, something like:  
2.99  
5.99  
6.99

I would like to have a variable that contains a result like this:  
2.99, 5.99, 6.99

I have tried and tried different approaches but nothing seems to work.  
I tried something like:  
$newPrice = $newPrice . ", " . $price;

Please help! Thanks in advance,

Leo :hair:

Here is the code:

```php

$sqlSession = "SELECT * FROM SHOPPERTRACK WHERE sessionid = '$sessionid' AND customerid = '$customerid'";
$resultSession = mysql_query($sqlSession) or exit("<p class='alert'>Could not get session information.</p>");
while($rowProduct = mysql_fetch_array($resultSession))
{
$price = $rowProduct["price"];
echo "<p>" . $price;
}

```
