# My MySql Query not working correctly

**URL:** <https://forum.kirupa.com/t/my-mysql-query-not-working-correctly/220895>\
**Category:** Uncategorized\
**Created:** [March 30, 2007, 5:30am UTC](https://forum.kirupa.com/t/my-mysql-query-not-working-correctly/220895 "2007-03-30T05:30:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flash\_Man1](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Flash\_Man1](https://forum.kirupa.com/u/Flash_Man1)\
**Post date:** [March 30, 2007, 5:30am UTC](https://forum.kirupa.com/t/my-mysql-query-not-working-correctly/220895/1 "2007-03-30T05:30:29Z")

</div>

Hey all,

i have a mysql query which works fine and pulls the corrcet data it just when i try and print it to a single or essentially (a dynamic text field in flash) which i have done before but for some reason it’s not working this time round.

I have 3 results in the database under the field suburb and i want all 3 of these results to appear on the one line/ in the one dynamic textfield on one line.

ATM i only get one suburb showing instead of three?  
My take on it i think i’m missing a loop or something?

Maybe a fresh set of eyes will help???  
Here is the code below:

```php
<?php

$suburbs = $_POST['suburbs_vars'];

mysql_pconnect("$server", "$user", "$pass") or die (mysql_error());
mysql_select_db("$database") or die (mysql_error());

$sql = "SELECT suburb FROM `mytable` ORDER BY `suburb` ASC";
$result = mysql_query( $sql );

while ($line = mysql_fetch_array($result)) {
    printf("Suburb: %s", $line[0]);
    $ourtext = "suburbs_vars=" . $line['suburb'];
    
}
print($ourtext);

mysql_free_result($result);

?>

```
