defcon2000 Posted March 29, 2006 Share Posted March 29, 2006 Hello All,We have a table in MySQL that we extract into an array as follows:$tmpdetails = mysql_query("SELECT * FROM params", $conn) or die('Query failed: ' . mysql_error()); $details = mysql_fetch_array($tmpdetails, MYSQL_ASSOC);The table is called params and has the following fields and data:[b]Id parameter detail[/b]1 smtpserveraddress blowfish.com2 serveraddress 192.168.0.103 copyinvoiceto jane@blowfish.com4 billingemailaddress billing@blowfish.com5 localcurrencysymbol GMDWe want to be able to access the result without having to loop through the array. We want to use the results of parameter as a reference point to access detail.For example, we want to access the result "192.168.0.10" using "serveraddress" in an array type format.Thanks in advance for your help. Quote Link to comment https://forums.phpfreaks.com/topic/6078-putting-data-into-a-multi-dimentional-array/ Share on other sites More sharing options...
Barand Posted March 29, 2006 Share Posted March 29, 2006 Try[code]$tmpdetails = mysql_query("SELECT * FROM params", $conn) or die('Query failed: ' . mysql_error());$param = array();while ($details = mysql_fetch_array($tmpdetails, MYSQL_ASSOC)) { $param[$details['parameter']] = $details['detail'];}[/code]Now[code]echo $param['serveraddress'];[/code]--> 192.168.0.10 Quote Link to comment https://forums.phpfreaks.com/topic/6078-putting-data-into-a-multi-dimentional-array/#findComment-22067 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.