I have had success in entering a block (many lines) of text into MySQL using PHP on my remote server and can read it back and display - Yipee (well it is a big achievement for a newbie)!
Now I am trying to find a way to edit the text and update the database entry.
I know there are some great editors but I really just need a kick in the direction of how I can go. I tried loading a variable into a textarea but can't seem to do it - get the variable name but not the content. Maybe I have to use Javascript (any hints?) Can I do anything in PHP?
For example how does this thread editor and update work. I know I will kick myself as it is probably staring me in the face but hey its late and I have run out of books with examples ;-)
All help appreciated.

David from Downunder. :bemused:

    your on the right track. load the data into a textarea. remember, text area's dont have a value element.

    <textarea name="data"><?php echo $data; ?></textarea>

    you'll also need to pass an id, or something to varifiy which record you want to update.

    <input type="hidden" name="id" value="<?echo $id; ?>">

    then submit this to a script which will run an UPDATE statment. its almost exectly like inserting new data, but instead your query might look something like.

    UPDATE tbl SET fld = '$_POST['data']' WHERE id = $id;

    hope this is enough of a kick in the right direction.

      OUCH -- well I am moving!! Thanks send you an update on how things develop! Why can't the books tell you this. Can editors (like this thread editor) be completely done in PHP or is some client scripting involved?

        its javascript. php would be very inifficient for something like that. things like that are best done on the client.

        there are free ones a around. have a look at FCKeditor.

          
          .........snip
          
          $edittitle= $row[PageTitle];
          $editpage= $row[PageContent];
          
          //the variables above print correctly
          
          
          ?>
          <H1>DOCUMENT ENTRY FORM</H1>
          <FORM METHOD= "POST" ACTION="enterediteddoc.php"
          <P><strong>Page Title</strong><BR>
          <INPUT TYPE="text" NAME="EnteredEditedTitle" size="20"><?php echo $edittitle; ?></P>
          <P><INPUT TYPE="HIDDEN" NAME="id" VALUE="<? echo $Catnum; ?>"></P>
          <P><STRONG>Page text:</STRONG><BR>
          <TEXTAREA NAME="EnteredPageText" COLS=100 ROWS=30><?php echo $editpage; ?></TEXTAREA>
          <P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="EnterEditedDoc"></P>
          
          </FORM>
          
          
          //Form is completely empty. $edittitle and $editpage do not appear in TextArea
          

            there are free ones a around. have a look at FCKeditor.

            How easy is it to move variables brought back to client side from MySQL and then with 'magic' get read into FCKeditor. A lot of what I read expects a 'text file' but if you save in text in MySQL have I got a problem? What is the file when you select into $result? Sorry to be such a newbie!! :bemused:

              maybe you need to take a look at a html forms tutorial first. input elements use a value attribute, so your variable will need to go in there. as for your textarea, if your variable is echoing correctly there is no reason it shouldn't be working.

              also note that capitals are invalid in html.

              as for your other question. as far as i can remember, using FCKeditor is no different to any other form.

                ps: i see another problem now. you never closed your opening form tag. this...

                <FORM METHOD= "POST" ACTION="enterediteddoc.php"

                should be...

                <form method="post" action="enterediteddoc.php">

                  FCKeditor crashed as it has ASP files which are not supported on my Apache (Linux) server. Anyone got a pure PHP text edit program I could develop and learn from.

                  Things working well now though not very impressive. Need more help in editing within a textarea. (Impressed it interprets some html tags and hrefs.)

                  How does Wiki add its automatic links?

                    Anyone got a pure PHP text edit program I could develop and learn from

                    as i already said, these things run on the client, and are written in javascript.

                    FCKeditor works exactly the same with php as it does with asp (it should also include some php examples), ive used it with both. if your not happy with it, why not search google for web based WYSIWYG editors?

                    if you just want simple [link][/link] type tags, do a google for php bbcode.

                      10 months later
                      Write a Reply...