There is a table "table" in it a column with data. and I need to display this column with a string ...

$result1 = mysql_query("SELECT * FROM table",$db); while ($myrow1 = mysql_fetch_array($result1)) { $count = $myrow1['id']; echo "$count"; } 

it turns out only the same column (On each circle of the cycle, it makes it on a new line / n. How to make this conclusion in a line?

  • one
    Before diving into working with a DBMS, it can be useful to understand the basics of a language. - Nofate

3 answers 3

 $result1 = mysql_query("select group_concat(id separator ' ') from table",$db); echo current(mysql_fetch_array($result1)); 

Well, if even after that you will have output in a column, it will mean that you have records in the table with a newline at the end. and you can remove it by changing the request to

 select group_concat(trim(trailing '\n' from 'id') separator ' ') from table 

    You can make a request:

     select group_concat(столбик) from table; 

    If you need a space, then:

      select group_concat(столбик separator ' ') from table; 
       $result1 = mysql_query("SELECT * FROM table",$db); while ($myrow1 = mysql_fetch_array($result1)) { $count = $count.$myrow1['id']." "; } echo "$count"; 
      • Well, I asked not to add the data, but output to the line .. - Alexander666
      • and I need to see all the data that is in the array, so I need to put the bracket after echo - Alexander666
      • I forgot about the features of concatenation. Updated. - Nofate
      • only here Notice: Undefined variable: count in /var/www/localhost/htdocs/blog/reit.php on line 18 I declare $ count = 0; There is no error, but this zero adds to the result ... - Alexander666