Hi!
I have working code (for a change!) for a script which edits information stored in a db.. When the db is successfully edited, MySQL displays a message that it's been done successfully. Currently, it echoes outside the table and is not aesthetically pleasing. How do I get it to echo in the table, rather than above it?
Here's the code:
<?php
// Connect to database
$connect= mysql_connect("localhost","root")
or die("Could not connect to database in localhost !");
mysql_select_db("testdiw")
or die("Could not select that database !");
if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'update')
{
$id = $_REQUEST['id'];
$_GET['id'] = $id;
$query = "UPDATE `acctmgr` SET acctmgr_name = '".$_REQUEST['newacctmgr_name']."',acctmgr_phone = '".$_REQUEST['newacctmgr_phone']."',acctmgr_cellphone = '".$_REQUEST['newacctmgr_cellphone']."',acctmgr_email = '".$_REQUEST['newacctmgr_email']."' WHERE id='$id'";
$result = mysql_query($query) or die("<b>mySQL Error:</b>".mysql_errono()."<br>".mysql_error());
if(!$result)
{
echo 'Error processing request.';
}
else
{
echo 'Request processed successfully.';
}
}
$id = $_GET['id'];
// The ID is passed through the URL to specify the row,
// Or it is set in the previous script.
$query = "SELECT * FROM acctmgr WHERE id = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo '<form name="update" method="post">
<input type="hidden" value="update" name="action">
<input type="hidden" name="id" value="'.$id.'">
<TABLE BORDER>
<TR>
<TD><B>Account Manager Name</B></TD>
<TD><input type="text" name="newacctmgr_name" size="40" value="'.$row['acctmgr_name'].'"></TD>
</TR>
<TR>
<TD><B>Phone Number</B></TD>
<TD><input type="text" name="newacctmgr_phone" size="12" value="'.$row['acctmgr_phone'].'"></TD>
</TR>
<TR>
<TD><B>Cell</B></TD>
<TD><input type="text" name="newacctmgr_cellphone" size="12" value="'.$row['acctmgr_cellphone'].'"></TD>
</TR>
<TR>
<TD><B>Email Address</B></TD>
<TD><input type="text" name="newacctmgr_email" size="32" value="'.$row['acctmgr_email'].'"></TD>
</TR>
<TR>
<TD COLSPAN=4><input type="submit" value="Update"> </form></TD>
</TR>
</TABLE> ';
?>