如何在mysql的单个字段中插入多个值

如何在mysql的单个字段中插入多个值

问题描述:

我想在一个字段中插入多个值,但我不知道如何实现,因为我使用的是长文本数据类型字段.并且还告诉我如何一次只获取一个单独的值来获取这些值.

i want to insert multiple values into a single field, i don't know how to achieve this i'm using a long-text data type field. And also tell me how to fetch these a value only one separate value at a time.

将多个值插入单个字段:

要在一个字段中插入单位号,请使用implode并将值用逗号分隔.

For inserting the flat no's in a single field, use implode and the values separated by comma.

$r=implode(",",$available);
$insert=mysql_query("insert into flatdetails(available) value ('$r')")

要从数据库中检索值,请使用explode分隔所有值.

For retrieve the values from database use, explode to separate out all the values..

用于使用检索值 $ i = explode(,",$ r);

<?php
$select_tbl=mysql_query("select * from flatdetails",$conn);
while($fetch=mysql_fetch_object($select_tbl))
{
$r=$fetch->available;


$i=explode(",",$r);


echo $i[0]."</br>";
}
?>