UPDATE data from db to user to db through an input field. Can anyone please tell me whats wrong with this UPDATE. I'm getting the data from a field where I'm also writing from db, is that not possible?
My sql code looks like this..
<?php session_start(); $brugerID = $_SESSION['brugerID']; $holdID = $_SESSION['holdID']; ?>
My php code looks like this:
<form method="POST" action="" id="submitvaegt">
<tr>
<td colspan="5"><h2>Hvor meget vejer du idag?</h2></td>
</tr>
<?php
$brugerensID = $_SESSION['brugerID'];
$sql = "SELECT * FROM `brugere`
WHERE brugerID = '$brugerensID'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo '<tr>';
echo '<td rowspan="3" valign="middle" width="128">';
echo '<img src="http://www.mahogni.com/afs/wp-content/uploads/2012/12/weight.png" width="60"></td>';
echo '<td> </td>';
echo '<td colspan="3"> </td>';
echo '</tr>';
echo '<tr>';
echo '<td width="245" height="35">Jeg vejer i dag</td>'; //vaegtnu
echo '<td width="280">';
echo '<input class="textboxReport" type="text" name="vaegtnu" size="3" value="';
if ($row['vaegtnu']==0)
{
echo $row['vaegtstart'];
}
else
{
echo $row['vaegtnu'];
}
echo '"/> kg ';
echo '<input type="submit" name="submitvaegt" id="submitvaegt" value="GEM" />';
echo '<td width="280" height="35">Jeg har til nu tabt</td>'; //vaegtstart - vaegtnu
echo '<td align="right">';
if ($row['vaegtnu']==0)
{
echo $row['vaegtstart']-$row['vaegtstart'];
}
else
{
echo $row['vaegtstart']-$row['vaegtnu'];
}
echo ' kg</td>';
echo ' </tr>';
echo '<tr>';
echo '<td height="35">Mit mål er</td>'; //vaegtslut
echo '<td>'. $row['vaegtslut'] . ' kg</td>';
echo '<td height="28">Jeg mangler at tabe</td>'; //vaegtslut - vaegtnu ELLER vaegtslut - vaegtstart
echo '<td>';
if ($row['vaegtnu']==0)
{
echo $row['vaegtslut']-$row['vaegtstart'] . ' kg';
}
else
{
echo $row['vaegtslut']-$row['vaegtnu'] . ' kg';
}
echo '</td>';
echo '</tr>';
?>
</form>