Show if hides update fields, but they get overwritten with an empty string

This is one of those ones that probably falls between PHP and SQL stuff.

Basically I have a page where some update fields are displayed depending on who is logged, for example:


<?php if ($row_Users['UserID']=="101"){ ?>
<input <?php if (!(strcmp($row_lodges['101_finalist'],"Yes"))) {echo "checked=\\"checked\\"";} ?> type="checkbox" name="101_finalist"  value="Yes"/>
<input type="text" class="rankfield" name="101_rank" value="<?php echo($row_lodges['101_rank']); ?>" />
<?php }  ?>
<?php if ($row_Users['UserID']=="102"){ ?>
<input <?php if (!(strcmp($row_lodges['102_finalist'],"Yes"))) {echo "checked=\\"checked\\"";} ?> type="checkbox" name="102_finalist"  value="Yes"/>
<input type="text" class="rankfield" name="102_rank" value="<?php echo($row_lodges['102_rank']); ?>" />
<?php }  ?>

The issue I have is that if User101 is logged in and updates fields 101_finalist and 101_rank, it overwrites 102_finalist and 102_rank with an empty string.

Is it possible to prevent each user from seeing the other fields for other users, and prevent the existing values for those other users not be overwritten?

Hope that makes sense!

Thank you.

It’s hard to say without seeing what you do with that data and some idea of how your table is populated. On the face of it, I’d handle the selection of which fields to update differently than you have, as it seems as if the code will get very complicated as you get more possible user IDs. But if your query to update the data takes all the form data and writes it to your table, surely all you need to do is surround the query with selections based on the user ID as you have for the display?


switch (rowUser['ID']) {
   // case '100':
   // do the query to update user 100 information
  break;
case '101':
  // do the query to update user 101 information
  break;
}

But it’s hard to say without knowing what you do next.