matt.k Posted March 9, 2006 Share Posted March 9, 2006 What im trying to do here is pull information from a MySQL database. And put all the data into an array. Basicly. Im pulling the collum names from an external file and i am reading it in the php script. As it reads each line and will grab the data from the collum which is named the same. So. If i opened up XYZ.txt and was reading it. And the first line said Servers. It would goto the Table and pull the info from the 'Servers' collum. I was wondering if this syntax will work. Havent had a change to try it out yet. And wont be able to for a little bit.$x will be the collum name of the current Table .. and $rs is obviously the data from the record set.$UserData = Array ($x => $rs)so if i put in echo $UserData[Servers] .. i would need it to print out the data from that collum in the DB. which would be already stored in that VAR. so output for example would be 192.168.1.1. Does the array have to be constant? I know some languages you have pre defined. and you are unable to just set it as something throughout the application. like.. in VB .. you have to say UserData(0 to 100). Is this the same case for PHP? or will the above piece of code work? If this code does not work. Does anyone have any suggestions on how to do something similarThanks in advance for the help!!! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 9, 2006 Share Posted March 9, 2006 Arrays in PHP are dynamic.You can write this:[code]<?php $UserData = Array ($x => $rs); ?>[/code]as[code]<?php $UserData[$x] = $rs; ?>[/code]Read [a href=\"http://www.php.net/array\" target=\"_blank\"]this section[/a] in the fine manual for more information.Ken 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.