Problem in editing a record
| From: | Miguel A.Galván | Date: | Thu, 31 Jan 2002 02:42:16 +0000 |
| Subject: | Problem in editing a record | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16338@lists.php.net to get a copy of this message | ||
Hi ...
I´m writing a code in order to update daily activities, these activities
are going to be saved in 3 daily records (depending of the schedule of
workers and their session id´s). I´ve already got records registered in
my DB ,but the problem comes when i´m trying to edit these records to
add a new activity, it displays all records ok but when i choose one in
order to edit it ,it displays and edit only the last one.
Can somebody help me??
Thanks ...
This is the script i´m trying for :
<html>
<body>
<?PHP
$db = @mysql_connect("localhost", "root", "****");
mysql_select_db("bitacora",$db);
if ($nombrebit) {
if ($submit) {
$sql = "UPDATE bitacora SET actividades='$actividades' WHERE
nombrebit like '$nombrebit'";
$result = mysql_query($sql);
echo " Informacion actualizada.\n";
} else {
// query the DB
$sql = "SELECT * FROM bitacora ";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<table border = 0>
<tr><td>
<form method="post" action="<?php echo $PHP_SELF?>">
Usuario:</td><td><input type="Text" name="usuario"
value="<?php echo
$myrow["usuario"] ?>"></td></tr>
<tr><td>Fecha:</td><td><input type="Text"
name="fecha" value="<?php
echo $myrow["fecha"] ?>"></td><tr>
<tr><td> Actividades:</td><td>
<textarea rows="12" cols="80" style="width:100%"
name="actividades"
class="postform">
<?php echo $myrow["actividades"] ?>
</textarea>
</td>
</tr>
<tr><td> Bitacora:</td><td><input type="Text"
name="nombrebit"
value="<?php echo $myrow["nombrebit"]
?>"></td></tr></table>
<input type="Submit" name="submit" value="Agregar
informacion">
</form>
<?php
}
} else {
// Despliega bitacoras
$result = mysql_query("SELECT * FROM bitacora ",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?nombrebit=%s\">%s %s</a><br>\n",
$PHP_SELF,
$myrow["nombrebit"], $myrow["usuario"], $myrow["nombrebit"]);
}
}
?>
</body>
</html>