salam...nk tnye ape mlsh edit.php...bla nk update ...juz kuar info title shje...description n image xkuar..tp ia msuk dlm databse if sy update ,cume bla display kt edit.php je , ia jdi blank for image n description...cmne nk atsi mslh nie..harap abg2 n kak2 kt cni dpt bantu sy
nie code
nie code
- Code:
<html>
<head></head>
<body>
<!-- standard page header -->
<?php
//open database connection
//var utk database
$username = 'root';
$password = '';
$database = 'suke';
$con = mysql_connect('localhost',$username,$password) or die ("Error connecting to database");
$sel = mysql_select_db($database) or die ("Error selecting database");
// generate and execute query
$id = $_GET['id'];
$query = ("SELECT title,image,description FROM pic WHERE id = '$id'");
$result = mysql_query($query)
or die ("Error in query: $query. " . mysql_error());
// if a result is returned
if (mysql_num_rows($result) > 0)
{
// turn it into an object
$row = mysql_fetch_object($result);
?>
<table cellspacing="5" cellpadding="5">
<form method="POST" action="update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<tr>
<td valign="top"><b><font size="-1">Title</font></b></td>
<td>
<input size="50" maxlength="250" type="text" name="title"
value="<?php echo $row->title; ?>">
</td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Description</font></b></td>
<td>
<textarea name="description" cols="40" rows="10"
value="<?php echo $row->description; ?>"></textarea>
</td>
</tr>
<tr>
<td valign="top"><font size="-1">Image</font></td>
<td>
<input type="file" name="myfile" size="45"
value="<?php echo $row->image; ?>">
</td>
</tr>
<tr>
<td colspan=2>
<input type="Submit" name="submit" value="submit">
</td>
</tr>
</form>
</table>
<?php
}
// no result returned
// print graceful error message
else
{
echo '<font size=-1>That press release could not be located ↵
in our database.</font>';
}
?>
<!-- standard page footer -->
</body>
</html>