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 [email protected]4 billingemailaddress [email protected]5 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. 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 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
Archived
This topic is now archived and is closed to further replies.