×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Create a php input form with uneditable fields populated from another table

Create a php input form with uneditable fields populated from another table

Create a php input form with uneditable fields populated from another table

(OP)
I have a donation list page that displays data from the donation and donor tables. I put a record edit link on each row and on the record edit page where I know have the donor_id I'd like to display the donor name (stored in the donor table) associated with that donation record but have it locked so the user can't change that information on that page.

Code right now...

CODE

<?php 
    $id = $_GET['id'];
	$sql = "SELECT * FROM donations WHERE donor_id = '$id'";
	$result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result);

//Extract fields.
  $donor_id=$_POST['donor_id'];
  $date=$_POST['date'];
  $amount=$_POST['amount'];
  $donation_cat=$_POST['donation_cat'];
  $miscellaneous=$_POST['miscellaneous'];
  $note=$_POST['note'];
	
  ?>
  
   <h1>Donation Details</h1>
   <div class="table-sortable:default">
   <p style="margin-left:25px;"> Edit Donation Record</p>
<form action="updateDonation.php" method="post">
<input type="hidden" name="id" value="<? echo $id ?>" />
<table>
 <tr><td>Donor: </td></td><td><input type="text" name="donor_id" value="<?php echo $row['donor_id']; ?>"></td></tr>
 <tr><td>Date: </td></td><td><input type="text" name="date" value="<?php echo $row['date']; ?>"></td></tr>
 <tr><td>Value: </td></td><td><input type="text" name="amount" value="<?php echo $row['amount']; ?>"></td></tr>
 <tr><td>Catagory: </td></td><td><input type="text" name="donation_cat" value="<?php echo $row['donation_cat']; ?>"></td></tr>
 <tr><td>Item: </td><td><input type="text" name="miscellaneous" value="<?php echo $row['miscellaneous']; ?>"></td></tr>
 <tr><td>Note:  </td><td><input type="text" name="note" value="<?php echo $row['note']; ?>"></td></tr>
</table>
<p style="margin-left:25px;"><input type="submit"></p>
</form> 

Yes I know I'm using an older code version. Switching in the middle of this project will confuse me even further. Once everything is working I'll start learning the new stuff and rewrite the code and it will make more sense to me.

Thanks!

RE: Create a php input form with uneditable fields populated from another table

I'm not sure there is a question in there.

It looks like you know how to pull information from the database, and echo it out.

To make it non-editable, just don't put it in an input box. Yes, you can make input fields "read-only" - but that also exposes an additional field POST/GET field unnecessarily.

Otherwise you have two options, mark it as readonly or disabled.

CODE --> HTML

<input type="text" value="This Value" readonly="readonly" />
<input type="text" value="This Value" disabled="disabled" /> 

RE: Create a php input form with uneditable fields populated from another table

(OP)
Thanks Borvik! This should work.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close