acctman Posted August 30, 2008 Share Posted August 30, 2008 <?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. Link to comment https://forums.phpfreaks.com/topic/121954-solved-inserting-array-data-into-mysql-fields/ Share on other sites More sharing options...
acctman Posted August 30, 2008 Author Share Posted August 30, 2008 any ideas on how to do this? Link to comment https://forums.phpfreaks.com/topic/121954-solved-inserting-array-data-into-mysql-fields/#findComment-629633 Share on other sites More sharing options...
Barand Posted August 30, 2008 Share Posted August 30, 2008 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'"); Link to comment https://forums.phpfreaks.com/topic/121954-solved-inserting-array-data-into-mysql-fields/#findComment-629657 Share on other sites More sharing options...
acctman Posted August 30, 2008 Author Share Posted August 30, 2008 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? Link to comment https://forums.phpfreaks.com/topic/121954-solved-inserting-array-data-into-mysql-fields/#findComment-629697 Share on other sites More sharing options...
acctman Posted August 31, 2008 Author Share Posted August 31, 2008 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 ) Link to comment https://forums.phpfreaks.com/topic/121954-solved-inserting-array-data-into-mysql-fields/#findComment-630478 Share on other sites More sharing options...
Barand Posted September 4, 2008 Share Posted September 4, 2008 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 Link to comment https://forums.phpfreaks.com/topic/121954-solved-inserting-array-data-into-mysql-fields/#findComment-633564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.