1

Php mysql- getting back a list of names from sever not working if list contains more that one entry. I'm thinking it this line $data .= "bffname=".$row->bffname; any advice would be most sincerely appreciated.

One name in the list

gets bffname=graham

two names in the list

gets bffname=grahambffname=bobby

PHP

 $username = $_POST['username'];
$dbTable = "`".$username."_Friend`";


// getting data
$data = "";
$res = mysql_query("SELECT * FROM ".$dbTable." ORDER BY id") or die(mysql_error());
while($row = mysql_fetch_object($res)) {
    $data .= "bffname=".$row->bffname;

}
John Conde
  • 217,595
  • 99
  • 455
  • 496
shelfish
  • 73
  • 2
  • 12

1 Answers1

1

There is no error in your question. The question is a bit indirect.

I guess you want to know how to disply the names one per line, right?

I've appended a new line (\n):

$data .= "bffname=".$row->bffname."\n";

I guess a HTML break would also work for you:

$data .= "bffname=" . $row->bffname . "<br>";
Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • Maybe this basic MySQL example is of help, too: http://www.php.net/manual/en/mysql.examples-basic.php Maybe you want to display a table? See the comment // Printing results in HTML – Jens A. Koch Jan 27 '14 at 15:20