# How would i do this...? \[php\]/\[mysql\]

**URL:** <https://forum.kirupa.com/t/how-would-i-do-this-php-mysql/247898>\
**Category:** programming\
**Created:** [December 31, 2007, 11:49pm UTC](https://forum.kirupa.com/t/how-would-i-do-this-php-mysql/247898 "2007-12-31T23:49:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisclick](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/chrisclick/32/1991_2.png) [@chrisclick](https://forum.kirupa.com/u/chrisclick)\
**Post date:** [December 31, 2007, 11:49pm UTC](https://forum.kirupa.com/t/how-would-i-do-this-php-mysql/247898/1 "2007-12-31T23:49:40Z")

</div>

Ok, im trying to make my footer use a mysql database instead of a text file…

but im having some problems…  
I am using the code to get the mysql data:

```php

$dbhost = 'localhost';
$dbuser = 'designs1';
$dbpass = ' *****';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'designs1_footer';
mysql_select_db($dbname);

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$query = "SELECT * FROM footer ORDER BY RAND() LIMIT 1";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
             $row['comment'];
}
mysql_close($conn);

```

That works fine. but i cannot put that into to footer code, it doesnt work if I try:

```php

$string = while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
             $row['comment'];
}

```

it works if I use

```php

$string = $array[0];

```

but it only shows ONE letter from the whole word…

So does anyone know how to do this?
