[thelist] matched pairs php + mysql

Maximillian Schwanekamp lists at neptunewebworks.com
Sat Sep 18 21:07:07 CDT 2004


Andrew wrote:

>I want to store a set of data in one field of a table that can be pulled
>out and formatted the same way that it was input ( style).
>
>eg I have a table with say 6 rows 6 columns the data input will be stored
>in one field (presumably seperated by  a comma, the data can then be
>pulled out and presented in the same way it was input, ie if r3 c4 contain
>data that is where it will be displayed on the fronted?
>  
>
Not sure why you would do it this way, but perhaps PHP's serialize() and 
unserialize() would work for you here.  Your tabular data can be 
represented as an array of arrays (e.g. $arrTable), which can then be 
made into a string for storage in MySQL using serialize($arrTable).  On 
output, you would pull the data from MySQL, and use unserialize() to 
convert the string data back into your array.  If you need to go 
further, you can serialize() entire objects as well - but note the 
caveats described in PHP manual.

All this said, you might give a little more detail about what you're 
doing - maybe someone here will have a more robust solution.  Presenting 
tabular data is a classic SQL task.

-- 
Maximillian Von Schwanekamp
Dynamic Websites and E-Commerce
NeptuneWebworks.com <http://www.neptunewebworks.com/>
voice: 541-302-1438
fax: 208-730-6504



More information about the thelist mailing list