473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Editing and Updating Text

I'm trying to create a text editing and updating capability to help
someone who wants to maintain content on a web page without having to
know any HTML or use a web authoring tool and FTP'ng the contents.
I've already created a screen whereby the person can create new
content with a PHP program that inserts into a MySQL table. But, I'm
having a little trouble in creating the edit/update functionality.
Can somebody help me out? Thanks.

I created an edit screen called "teach_edit.php". Based upon some
search parameters on another HTML screen, it retrieves the appropriate
text from the database. It seems to allow on screen editing.
However, when I hit the Submit button, nothing happens. It's supposed
to call another program called "teach_update.php". Here's the code
for it.

<HTML>
<HEAD>
<TITLE>Teaching Edit Program</TITLE>
</HEAD>
<BODY>
<?php
@ $db = mysql_connect('localhost', '<db name>', '<password>');
if (!$db)
{
echo "Error: Could not connect to database. Please try again
later.";
exit;
}
mysql_select_db("<db>");
$query = "select * from albert where ".$searchtype." like
'%".$searchterm."%'";

$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$title = $row['title'];
$teaching = $row['teaching'];
$teaching = wordwrap($teaching, 60, "\n", 1);
$teachnum = $row['teachnum'];
}
if ($result)
{

echo '<textarea name="teachnum" rows="1" cols="4"
wrap="off">';
echo htmlspecialchars($teachnum)."\n";
echo '</textarea>';
echo '<textarea name="title" rows="1" cols="60" wrap="off">';
echo htmlspecialchars($title)."\n";
echo '</textarea>';
echo '<textarea name="teaching" rows="20" cols="80"
wrap="on">';
echo htmlspecialchars($teaching)."\n";
echo '</textarea>';

}

?>

<input type=submit value="Update" name="teach_update.php">
</form>
</BODY>
</HTML>

The "teach_update.php" looks like this.

<HTML>
<HEAD>
<TITLE>Teaching Update Program</TITLE>
</HEAD>
<BODY>
<?php
@ $db = mysql_connect('localhost', '<database>', '<password>');
if (!$db)
{
echo "Error: Could not connect to database. Please try again
later.";
exit;
}
mysql_select_db("<db>");
$query = "update albert set title =". $title . " and teaching = ".
$teaching . " where teachnum =" . $teachnum ;
$result = mysql_query($query) or die("Could not update!");

if ($result)
{
echo mysql_affected_rows()." text item updated into
database.";
}
?>
</BODY>
</HTML>
Jul 17 '05 #1
0 1768

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dennis Marks | last post by:
There are times that I am using another person's computer who has no knowledge of updating HTML and does not even know if he has the necessary programs to do the FTP. I may see a minor problem...
3
by: Islamegy | last post by:
When i press btn_save all changed rows in my grid get saved except the last editing row... I want my btn_Save to end editing in the datagrid.. so if user didn't press "enter" after editing last...
1
by: Jeff Petter | last post by:
I can't seem to get the update piece working properly while doing in-place editing. I don't receive any errors, but the update doesn't take place. From the examples I've used as "go bys" it looks...
0
by: Patrick.O.Ige | last post by:
I have a XML file which is formed ! And its used with a treeView menu control. But the thing is that the TREEVIEW hasn't got a constant hieracrchy structure! which is difficult to Edit,insert or...
5
by: Ian Bicking | last post by:
I got a puzzler for y'all. I want to allow the editing of functions in-place. I won't go into the reason (it's for HTConsole -- http://blog.ianbicking.org/introducing-htconsole.html), except that...
0
by: skydiver_morgan | last post by:
I need some quick help with constructing a MYSQL query to help solve a small problem that I have. I havea table in my database where I need to search for text withing a field and delete it. The...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
1
by: siddu | last post by:
While i am Updating MyDataGrid Data it is not Updating and Even it is not Displaying any Error.. Sub MyDataGrid_UpdateCommand(ByVal source As Object, ByVal e As...
0
by: lazycoder207 | last post by:
hi i have a webbrowser control and textbox control in a form ..when application is starting up, webbrowser loads a page on my drive..that page links to a css style sheet..which has p {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.