Wildhalf Posted January 18, 2010 Share Posted January 18, 2010 Hi i want to search my table for a few specific enteries shown in the code below $multi_sql = "SELECT spon_email_1, spon_email_2,spon_email_3,spon_email_4,spon_email_5 FROM worthatry_spon WHERE aff_email = 'kieron@webdesign4u.ie'"; $multi_res = mysql_query($multi_sql) or die("An internal error has occured!<br />Unable to run the following query:<br /><pre>" . $qry. "</pre><br /><br />" . mysql_error()); $multi = mysql_fetch_array($multi_res); Now this SQL state works and returns exactly what i want it to. now once i have this information i would like to turn this array into a multidemensional array. I want the array to be 3 levels. ie ARRAY[1st_email][2nd_email][3rd_email] , now the results from the sql above are to be the list of 1stemails. I then want to search my table again and add the corresponding results to 2n_email positions in the array. And lastly with the 2nd_email results i want to search table again and return the 3rd_emails. Hope that helps. Anyone know how to convert my array into a multi-demensional array??? Quote Link to comment Share on other sites More sharing options...
al Posted January 18, 2010 Share Posted January 18, 2010 Try like this: $emails = array( $multi[1st_email] => array( $multi[2nd_email] => array($multi[3rd_email])), ); Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 18, 2010 Share Posted January 18, 2010 If you want to have, for example, your 3emails stored 2 levels down (1st => 2nd =>3rd) something like this might suffice. $emails = array( 'emails_1' => array( 'data' = array(), 'emails_2' => array( 'data' => array(), 'emails_3' => array( 'data'=>array() ) ) ) ); then when you are getting the emails // First $emails['emails_1']['data'] = $fetched_rows1; // Second $emails['emails_1']['emails_2']['data'] = $fetched_rows2; // Third $emails['emails_1']['emails_2']['emails_3']['data'] = $fetched_rows3; Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 18, 2010 Share Posted January 18, 2010 Missed a > $emails = array( 'emails_1' => array( 'data' => array(), 'emails_2' => array( 'data' => array(), 'emails_3' => array( 'data'=>array() ) ) ) ); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.