Consider the following table structure: TBL "lease_rates":
id lease_year classes_letter lease_rate
01 2010 A 123
02 2010 B 129
.. 2010 E 145
06 2011 A 131
etc.
What I want to do is take all of these values and put them into text boxes for editing and re-submission like so:
A B C D E
2011 131 ... ... ... ...
2010 123 129 ... ... 145
[Add a row] [Submit Edits]
I feel like the first thing I have to do is create an array of values based on lease_year and classes_letter, sort it, and then populate the text boxes.
I'm kinda stuck on how to do this. Once that's all populated, the submit button needs to update the table with the new values.
I started off here: http://www.phpeasystep.com/mysql/10.html but it didn't help much because I have repeating values that I want to sort by.
You could use three arrays, $years
(sorted), another $classes
(sorted) and a last one like this $arr[$year][$class] = $rate
. Then browse it like this :
foreach ($years as $year) {
foreach ($classes as $class) {
if ($arr[$year][$class] == null) {
echo '...';
} else {
echo $arr[$year][$class];
}
}
}
And if you need to keep track of its ID, instead of stocking directly the rate in the two dimensional array, store an array, or much better, an object (from something like a LeaseRate class).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.