lane87
12-17-2010, 04:31 PM
Hey Guys,
Sorry to bother you, im slightly stuck on updating a record in a database, i have an edit page with a form which shows a text box with text of a certain page in. Like this:
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Edit About Us English </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_update_english.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name="detail" cols="50" rows="4" id="detail">
<?php
mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());
mysql_query("SET names 'utf8'");
$result = mysql_query("SELECT body FROM aboutenglish WHERE ID = '1'");
// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
// Print out the contents of each row into a table
echo nl2br($row['body']);
?>
</textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
Im not sure if thats done correctly or not, but it does what i need to.
From there i can edit the text but when i click the submit button the database is blank.
The 'send form' code is like this:
<?php
// Details
$message="$detail";
mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());
mysql_query("SET names 'utf8'");
$result = mysql_query("UPDATE aboutenglish SET body = '$message' where ID = '1'");
?>
The actual update query works fine i think its just passing the values between the two pages i mean i have:
edit page:
<td><textarea name="detail" cols="50" rows="4" id="detail">
send form page:
$message="$detail";
$result = mysql_query("UPDATE aboutenglish SET body = '$message' where ID = '1'");
If anyone could help id really appreciate it.
Cheers
Sorry to bother you, im slightly stuck on updating a record in a database, i have an edit page with a form which shows a text box with text of a certain page in. Like this:
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Edit About Us English </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_update_english.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name="detail" cols="50" rows="4" id="detail">
<?php
mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());
mysql_query("SET names 'utf8'");
$result = mysql_query("SELECT body FROM aboutenglish WHERE ID = '1'");
// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
// Print out the contents of each row into a table
echo nl2br($row['body']);
?>
</textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
Im not sure if thats done correctly or not, but it does what i need to.
From there i can edit the text but when i click the submit button the database is blank.
The 'send form' code is like this:
<?php
// Details
$message="$detail";
mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());
mysql_query("SET names 'utf8'");
$result = mysql_query("UPDATE aboutenglish SET body = '$message' where ID = '1'");
?>
The actual update query works fine i think its just passing the values between the two pages i mean i have:
edit page:
<td><textarea name="detail" cols="50" rows="4" id="detail">
send form page:
$message="$detail";
$result = mysql_query("UPDATE aboutenglish SET body = '$message' where ID = '1'");
If anyone could help id really appreciate it.
Cheers