phpMyAdmin, change data

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kid_am
Forum Newbie
Posts: 7
Joined: Wed Nov 06, 2002 6:41 am

phpMyAdmin, change data

Post by kid_am »

sorry, i'm a newbie :D and i don't know how to change some data in a table. I only see a possibility to enter a whole new row... thx!
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Use something like this...

Code: Select all

<?php

$change_from_this="Bob";

$change_to_this="Mike";

mysql_query(" UPDATE `your_table` SET `name`='$change_to_this' WHERE `name`='$change_from_this' ");

?>

If you don't know the value you want to change then just do this..

Code: Select all

<?php

$change_to_this="Red";

mysql_query(" UPDATE `your_table` SET `colour`='$change_to_this' ");

?>

Hope this helps.
kid_am
Forum Newbie
Posts: 7
Joined: Wed Nov 06, 2002 6:41 am

Post by kid_am »

thx! but is it necessary to enter this whole stuff in phpmyadmin? Isn't there a much easier solution? thx anyway!
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Sorry I don't understand what you mean.

The above script would be used in a PHP page and unless you want to do it by deleting an old row and entering a new one it's basically the easiest way of changing data.

If you want to change the information manually then use phpmyadmin.

If you don't know how to use phpmyadmin then read the manual.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

slect browse

Post by phpScott »

In phpMyAdmin if that is what I understand you are using
On the left side select the table that has the row you wich to update.
Select browse and keep clicking the > button until you see the row that needs to be updated.
Click on edit, the page will the turn into a form that will allow you to edit the data.
At the bottom click save.

Or if you have a large table you can run an SQL query to limit the result set, but if you are going through that effort you might as well run a SQL script that uses UPDATE.

phpScott
Post Reply