Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 709931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:33:31+00:00 2026-05-14T04:33:31+00:00

I am trying to write a custom script that will keep a list of

  • 0

I am trying to write a custom script that will keep a list of strings in a textarea. Each line of the textarea will be a row from a table.

The problem I have is how to work the script to allow for adding, updating, or deleting rows based on a submit.

So, for instance, I currently have 3 rows in the database:
john
sue
mark

I want to be able to delete sue and add richard and it will delete the row with sue and insert a row for richard.

My code so far is as follows:

To query the db and list it in the textarea:
$basearray = mysql_query(“SELECT name FROM mytable ORDER BY name”);

<textarea name="names" cols=6 rows=12>');
<?php
   foreach($basearray as $base){
      echo $base->name."\n";
   }
?>
</textarea>

After the submit, I have:

<?php
$namelist = $_REQUEST[names];
$newarray = explode("\n", $namelist);

foreach($newarray as $name) {
   if (!in_array($name, $basearray)) {
      mysql_query(DELETE FROM mytable WHERE word='$name'");
   } elseif (in_array($name, $basearray)) {
      ;
   } else {
      mysql_query("INSERT INTO mytable (name) VALUES ("$name")");
   }
} 

?>

Please tell me what I am doing wrong. I am not getting any functions to work when I edit the contents of the textarea.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:33:31+00:00Added an answer on May 14, 2026 at 4:33 am

    The answer is simple. Don’t do it using textarea. That’s what you’re doing wrong.

    List your strings in HTML table, with “Edit” and “Delete” buttons.
    Edit your rows by one and you’ll never have any problem.

    As for your approach to treat a database as a plain text file, be consistent and think of it as a plain text file. So, it must be emptied before writing.

    Edit:
    Or – even much,much better – get rid of the database and use a txt file instead.

    So, your code become as simple, as

    <textarea name="names" cols=6 rows=12>');
    <?php readfile('base.txt') ?>
    </textarea>
    

    and form handler is

    <?php file_put_contents("data.txt",$_REQUEST['names']); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 343k
  • Answers 343k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your best bet would be to calculate the width the… May 14, 2026 at 5:30 am
  • Editorial Team
    Editorial Team added an answer (0...100).step(2) do |i| # loop body end May 14, 2026 at 5:30 am
  • Editorial Team
    Editorial Team added an answer Nothing in VB.net is the default value for a type.… May 14, 2026 at 5:30 am

Related Questions

I am working on porting over a database from a custom MSSQL CMS to
I am trying to find a good way to tail a file on a
I am trying to write a simple dialog that is called by the flash
I am trying to tap into the HTML.ValidationMessage() element to write so really custom
I am trying to write a custom code generator that can parse stored procedures.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.