php - insert and select strings array from database.? -
I want to put all the string array databases in one line, and after that, somewhere else only the first part They (wire array) and they (first part string array) are displayed by loop forward. I use [ Example: I want this output: then: then: serialized or
implode or
json_encode or
? ]? Can you give me an example?
Data (string array):
$ units = $ _REQUEST ['units' ]; $ Units = array_map ('mysql_real_escape_string', $ units); Mysql_query ("INSERT IN & lt; Table Name & gt; VALUES ('.' Implode (''), ('", $ units). "')");
$ q = mysql_query ('select & lt; by table name & gt;'); While ($ line = mysql_fetch_row ($ q)) {echo $ line [0]; Sometimes, however,
serialize is a better option:
$ units = $ _REQUEST ['units'] ; $ Units = array_map ('mysql_real_escape_string', $ units); Mysql_query ("INSERT & lt; Table Name & gt; VALUES ('.' Serialize ($ units)." ') ");
$ q = mysql_query (choose 'From & lt; Table Name & gt;'); While ($ line = mysql_fetch_row ($ q)) {$ units = unserialize ($ line [0]); } Var_dump ($ units); // Use foreach here
Comments
Post a Comment