I've been stuck on this for a little while now. Am sure there is an easy solution for this but I am still wrapping my head around php.
I want to get some data from a DB and save it into another.
Using SQL I managed to get that data and save it in an array. Now I want to convert that data into a string to save to a different array (if there is a way to do that directly without first saving into an array, then I am all ears).
I get my data in this format.
Array ( [0] => Array ( [0] => 414208 [InterestedEntityId] => 414208 [1] => 126.61370996251785 [Score] => 126.61370996251785 ) [1] => Array ( [0] => 479516 [InterestedEntityId] => 479516 [1] => 73.531040944194 [Score] => 73.531040944194 ) [2] => Array ( [0] => 4129769 [InterestedEntityId] => 4129769 [1] => 54.390965049372674 [Score] => 54.390965049372674 )
I want to convert it into:
414208 126.61370996251785
479516 73.531040944194
4129769 54.390965049372674
Here is my code:
$sql = mysql_query("SELECT Id, Score FROM users.`table1` WHERE UserId= $userID", $dbh1);
$table = array();
while ($row = mysql_fetch_array($sql))
$table[] = $row;
$table = implode($table);
mysql_query("INSERT INTO $tbl_name(table) VALUES ('$table')", $dbh2);
Can someone please help in this?