Thank you for the response to my question unfortunately your answer just
confused me even more.
Saturday, March 30, 2002, 4:25:40 PM, you wrote:
DSK> Run a while loop on your data and pull it into an array....
DSK> Heres an example (though this pulls from a text file the idea is the
DSK> same...) Hope this helps...
DSK> <?php
DSK> // READING THE DATA
DSK> function read_data($datafile) {
DSK> $data=file($datafile);
DSK> foreach ( $data as $line ) {
DSK> $temp=explode(':', $line);
DSK> $cp=$temp[4];
DSK> $return[$cp][]=$line;
DSK> }
DSK> if ( is_array($return) ) {
DSK> return($return);
DSK> } else {
DSK> return("NULL");
DSK> }
DSK> }
?>>
DSK> <?php
DSK> // USING THE DATA
DSK> $hosts=read_data('./hosts.dat');
DSK> if ( $hosts != 'NULL' ) {
DSK> $count=0;
DSK> foreach ( $hosts as $host ) {
DSK> $temp=explode(':', $host[0]);
DSK> $hostss.=str_replace("%%COMPANY%%",
DSK> decode($company=$temp[4]),$template_company_begin);
DSK> foreach ( $host as $hst ) {
DSK> $temp=explode(':', $hst);
DSK> $h_names[]=$temp[0];
DSK> $hostss.=str_replace("%%DISPLAY%%",
DSK> display_host($hst, $count),
DSK> $template_company_mid);
DSK> $count++;
DSK> }
DSK> $hostss.=$template_company_end;
DSK> }
DSK> } else {
DSK> $hosts="No Hosts In Database...<br>";
DSK> }
?>>
DSK> -----Original Message-----
DSK> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
DSK> Sent: Saturday, March 30, 2002 4:22 PM
DSK> To: php
DSK> Subject: [PHP] Pulling data into an array and sorting
DSK> I need to pull data into and array from a mysql database and then sort
DSK> that data according to one of the fields and then print it to the
DSK> screen.
DSK> Hear is an example of the data in the database
DSK> username Pnumber sec2 sec3 sec4 sec5 sec6
DSK> Gary 123.345.122 YES YES NO YES YES
DSK> Fred 123.345.123 YES YES NO YES YES
DSK> Jone 123.345.124 YES YES YES NO YES
DSK> Tom 123.345.124 YES YES NO YES YES
DSK> Frank 123.345.123 YES YES NO YES YES
DSK> If you will notice the Pnumber for some are the same and some are
DSK> different. I what to be able to sort on this number and then when they
DSK> are printed they would be printed according to this number in groups
--
Best regards,
rdkurth mailto:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php