Jim R Posted May 5, 2011 Share Posted May 5, 2011 I have a list that goes about 50 deep that I make changes to quite a bit. Each row has five columns, and the information sits on a database. Instead of making the changes in the database, I'd like to make the changes right on my site, so I can actually the list in order, then submit any changes. (It's just easier to look on my web page than the data table, and it's easier to grant the ability to change data on that page than give another data table access.) They are ordered by rankings 1-50. To do that, I'm picturing rows of data, printed in form elements instead of just printed statically on the page. From there I can make the changes I need (mostly to just the one column) then his Submit. Here is how the code looks now: <table class="playerTable" border="0" width="100%"> <thead> <tr> <th class="num">#</th> <th class="top">Top 10</th> <th class="height">HT</th> <th class="pos">POS</th>'; if (current_user_can("access_s2member_level4")){ echo '<th class="level">Level</th>'; } echo '<th class="school">City (School)</th>'; if (current_user_can("access_s2member_level4")){ echo '<th class="summer">Summer Team</th>'; } echo '<th class="college">College</th> </tr> </thead> <tfoot> <tr> <td colspan="8" align="right">(+) moved up; (d) debut; (s) switched from another position / <b>Colleges in bold print means committed</b></td> </tr> </tfoot> <tbody>';$query = 'SELECT * FROM wp_playerRank WHERE year="2011" ORDER BY rankClass ASC'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { if ($line['rankClass'] != 0) { echo ' <tr> <td>'. $line['rankClass'] . $line['devClass'] .'</td> <td>'; if ($line['wpID'] > '0') { echo '<a href="/tag/' . $line['nameFirst'] . '-' . $line['nameLast'] .'">'. $line['nameFirst'] . ' ' . $line['nameLast'] . '</a>'; } else { echo $line['nameFirst'] . ' ' . $line['nameLast']; } echo '</td><td>'. $line['height'] . '</td> <td>'. $line['position'] . '</td>'; I'm primarily interested in $line['rankClass'] being editable right on my web page. I"m seen syntax examples, but they have all been just changing one line at a time. I could theoretically make changes in all 50 rows. From a syntax perspective, I feel like I'm going to run into a NAME issue. Example: <input maxlength="5" name="rankClass" size="2" type="text" /> I realize I need to change "rankClass" to PHP that brings in the value from the data table. However, the PHP would also do that for 50 rows of data. Do I need to worry about duplicate instances being name="rankClass"? How would that look? Quote Link to comment https://forums.phpfreaks.com/topic/235572-update-using-a-pre-populated-form/ Share on other sites More sharing options...
vicodin Posted May 5, 2011 Share Posted May 5, 2011 Your gonna put the name like this... <input maxlength="5" name="rankClass[]" size="2" type="text" /> Now when PHP recieves that data it will be in an array. so it will be like this $_POST["rankClass"][0]; $_POST["rankClass"][1]; ... $_POST["rankClass"][49]; Quote Link to comment https://forums.phpfreaks.com/topic/235572-update-using-a-pre-populated-form/#findComment-1210777 Share on other sites More sharing options...
Jim R Posted May 5, 2011 Author Share Posted May 5, 2011 When it posts I don't have to worry about the name fields all being the same? From there I just need to associate the changed data to the static data (nameFirst, nameLast, id)? Quote Link to comment https://forums.phpfreaks.com/topic/235572-update-using-a-pre-populated-form/#findComment-1210816 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.