Jump to content

[SOLVED] Inserting Array data into mysql fields


acctman

Recommended Posts

<?php
$dbc = mysql_connect ($db_server, $db_user, $db_pass);
mysql_select_db ($db_name) or die(mysql_error());

$res = mysql_query("SELECT m_addtn FROM rate_members WHERE m_id = '39'");
$results = mysql_fetch_array($res,MYSQL_BOTH);

$decode = unserialize(base64_decode($results['m_addtn']));
print_r($decode);
?>

 

The coding above outputs and array of Array ( [3] => Single [6] => Involved [4] => I ADDED SOME NEW PICS [1] => THEY R IN THE MAIN 4 NOW )   what I need to do is insert each array into a separate field within the same row, Array[3] = m_status, Array[6] m_ori, Array[4] = m_turn1, and Array[1] = m_turn2. Once that's been tested and works I think need to do a Loop through the entire rate_member table and process every row.

you could try something like

 

list (,$m_turn2,,$m_status,$m_turn1,,$m_ori) = $decode; 
mysql_query ("UPDATE rate_members SET
             m_turn1 = '$m_turn1',
             m_turn2 = '$m_turn2',
             m_status = '$m_status',
             m_ori = '$m_ori'
             WHERE m_id = '39'");

you could try something like

 

list (,$m_turn2,,$m_status,$m_turn1,,$m_ori) = $decode; 
mysql_query ("UPDATE rate_members SET
             m_turn1 = '$m_turn1',
             m_turn2 = '$m_turn2',
             m_status = '$m_status',
             m_ori = '$m_ori'
             WHERE m_id = '39'");

 

I would put the LIST in the order of the decoded Arrays in the BLOB correct?

Is there a better to do it where I can associate the Array number with the field? ex. Array[3] = m_status

 

Array ( [3] => Single [6] => Involved [4] => I ADDED SOME NEW PICS [1] => THEY R IN THE MAIN 4 NOW )

 

That is exactly what my list() statement does.

0 - unused

1 - $m_turn2

2 - unused

3 - $m_status

4 - $m_turn1

5 - unused

6 - $m_ori

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.