0

asking for insert multiple lines in one mysql column (with something like line break like show didn't mean inserting data in multiple rows have multiple variables contain different urls like

want to store these values in one mysql column ever value should be in new line refer image describe better

asking for insert multiple lines in one mysql column (with something like line break like didn't mean inserting data in multiple rows

  • 2
    Possible duplicate of [Insert multiple rows with one query MySQL](https://stackoverflow.com/questions/12502032/insert-multiple-rows-with-one-query-mysql) – M. Eriksson Sep 10 '17 at 18:22
  • 1
    ^ and you should of course use MySQLi or PDO instead of the old and deprecated `mysql_*`-functions, but the query will still be the same. – M. Eriksson Sep 10 '17 at 18:23
  • @MagnusEriksson thank you for response but my problem is different i dont ask about insert in mulitple rows i want to insert in one column of one row multiple variables value but in multiple lines not mysql rows – Jawad Malik Sep 10 '17 at 18:31
  • Use `implode` and use a new line for the glue, then just insert that variable. – chris85 Sep 10 '17 at 18:36

1 Answers1

0

If you trying in php, then you can serialize the data and store as single column in DB.

While retriving data, we can unserialize and get the data as array. Find below example.

<?php
$var = array();
$var[0] = "http://example.com";
$var[1] = "http://example.org";
$var = array("1","2","3");
print_r($var); // Array ( [0] => http://example.com [1] => http://example.org ) 

$b=serialize($var);

echo $b; // a:2:{i:0;s:18:"http://example.com";i:1;s:18:"http://example.org";}

$c=unserialize($b);

print_r($c); // Array ( [0] => http://example.com [1] => http://example.org )