Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

update or delete all records

New Here ,
Nov 02, 2010 Nov 02, 2010

Hi everyone!

Im making a site with PHP, and wonder if i can achieve this:

First: Let's say that the db has 30 records in a table, and i want to change a particular data in all the records. How can i do this?

Second: In the same way, how can i delete all the records of that table?

For example:

table 'example'

cols id, title, content, description

If i want to "reset"(change it's value to none, for example) the 'description' value in all the records of that table, how can i do that?

And second: how can i truncate the whole table? (TRUNCATE = dump all the data inside the table, right?)

All of this from php, not from phpmyadmin lol!

Thanks in advance

Cheers!

TOPICS
Server side applications
813
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Nov 02, 2010 Nov 02, 2010

Like I said in the previous reply: use the UPDATE and DELETE MySQL commands. Look 'em up for examples. There's plenty of examples out there that will do what you want. Basic examples are:

UPDATE table_name SET column_name=something, column_name_2=sometingelse

or

DELETE FROM table_name where field = something.

Translate
Guest
Nov 02, 2010 Nov 02, 2010

You don't need php to do this, it's technically MySQL that does this.

use UPDATE,and DELETE functions in mysql. Look 'em up for examples. If you want to dump a table then use DUMP.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 02, 2010 Nov 02, 2010

Thanks for the reply IPHP

I know this actions are maded by mysql. But the site has an administrator section, and i wish to add that functionality IN the administrator page. For example, if i want to update a single record, i can do it trough the update form, build it with the prebuilded scripts in DW. But if i want to update ALL the records, what are the tweaks i need to make in that script to achieve this goal?

Like a link: when the user clic that link, the page linked take this action:

1º: Turn all the values from column 'description' in db 'example' to ' '

2º: After that, go to (some page)

Same mode to truncate the data in the table, not the table itself

Cheers!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 02, 2010 Nov 02, 2010

Like I said in the previous reply: use the UPDATE and DELETE MySQL commands. Look 'em up for examples. There's plenty of examples out there that will do what you want. Basic examples are:

UPDATE table_name SET column_name=something, column_name_2=sometingelse

or

DELETE FROM table_name where field = something.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 02, 2010 Nov 02, 2010
LATEST

So sorry IPHP, didn't understand you in the first reply

Thanks a lot!

I'm gonna look for this and see what happens

Cheers, and thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines