fat kid
Junior Member
Joined: Fri Apr 17, 2009 12:06 pm Posts: 8
|
Hi, thanks for the advice about the array. I'm going to need to update the months. Actually, I guess I should rephrase. I'll be working with dates, but it'll only be monthly data. The years will changes however. Also, the data is basically a bunch of different types of metrics -- delinquencies and what not. It'll be -- hopefully -- dealt with in percentages. The way its supposed to be set up is a state will show the monthly percent of a selected metric. Let me know if this sheds any light and thanks again for the response.
|
fat kid
Junior Member
Joined: Fri Apr 17, 2009 12:06 pm Posts: 8
|
Hi, I think this was what I needed...
[php] <?php $states = array('AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY'); $state = array(); $date = array(); $total = array(); for($i=0;$i<count($states);$i++){ $result = mysql_query("SELECT * FROM '$table' WHERE state='$states[$i]' ORDER BY id DESC LIMIT 14"); if($result) { while ($row = mysql_fetch_object($result)) { $state[] = $row->state; $date[] = $row->date; $total[] = $row->total; } } } echo "<?xml version='1.0' encoding='utf-8'?>\n"; echo "<items>\n"; for($j=0;$j<count($state);$j++){ echo "<state attribute='$state[$j]'>\n"; echo "<date attribute='$date[$j]'>\n"; echo "<total>" . $total[$j] . "</total>\n"; echo "</date>\n"; echo "</state>"; } echo "</items>"; ?> [/php]Now, I can find the latest entries. I THINK what would be best for my needs is to just have different tables set up basically how you showed me and use $table to load the different tables. Thanks again for your help!
I'll format the xml correctly later
|