Jump to content

UPDATE using a pre-populated form


Jim R

Recommended Posts

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?

Link to comment
Share on other sites

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];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.