Edit row of MySQL database table using a PHP form

I'm trying to populate a form with data from a MySQL database table using PHP. So then the user can edit the the row of data. I thought the code below would do the trick but data is not being displayed on the form. Attached I have the partial form to give you guys an idea of what I'm doing.

<input name="title" type="text" value="<?php echo $mysession['title']? id="title" size="70" maxlength="75"/>

Open in new window

<?php
session_start();
$_SESSION['id'];
$_SESSION['$myusername'];

$id = $_GET['id'];

?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>

<p>BACK TO <a href="../../index.php">ACCOUNT PAGE</a>	</p>
<p><a href="../../logout.php">LOGOUT</a></p>
<p>USE THIS FORM TO POST!</p>
<form method="POST" action="modifyform.php" enctype="multipart/form-data">
<input type="hidden" name="id" id="id" value="<?php echo $id; ?>" />
  <table width="729" border="0">
  <tr>
    <td width="111" height="68"><div align="right"><span style="color: #F00">*</span>Title</div></td>
    <td width="4"><div align="center">:</div></td>
    <td width="600"><label for="title"></label>
      <span id="sprytextfield4">
      <input name="title" type="text" value="<?php echo $mysession['title']? id="title" size="70" maxlength="75"/>

Open in new window

genesisvhAsked:
Who is Participating?
 
Ali KayahanConnect With a Mentor Full Stack DeveloperCommented:
can you please try ;

<td><label for="description"></label>
      <textarea name="description" cols="70" rows="25" id="description"><? echo $rows['description']; ?></textarea></td>
  </tr>
0
 
PranjalShahCommented:
I dont see any SQL statements here
0
 
chemdryCommented:
In your example are you passing anything to the page like ?id=123
If not then id isn't being set so no data will show up in the form field.

Now I don't know if your just testing how to populate a form field but the previous posting is right. Where is your sql query?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Jagadishwor DulalBraces MediaCommented:
I hope you already have select query and fetched records and displaying in your form for edit.
If not then first create your select query and fetch records which will display data in your form field but here I have seen

<input name="title" type="text" value="<?php echo $mysession['title']? id="title" size="70" maxlength="75"/>

Open in new window

You are fetching data from $mysession['title'] is that correct? if so than you should have sql statement before the above line like:

$query="SELECT title from yourtablename WHERE id=$id";
$mysession=mysql_fetch_row($query); //if this is correct than there should not be error

Open in new window

0
 
genesisvhAuthor Commented:
Ok so I really screwed up and got all the fields to show the results except one. I'm having trouble showing the data from a text area. This is what I have, how can I fix it.
<td><label for="description"></label>
      <textarea name="description" cols="70" rows="25" value="<? echo $rows['description']; ?>" id="description"></textarea></td>
  </tr>

Open in new window

0
 
genesisvhAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.