Jump to content
xisto Community
Sign in to follow this  
Mystixs

Editing Information In A Mysql Database And Deleting Rows

Recommended Posts

I need help with a couple of things.First, I need to know how to retrieve information from a mysql database and edit it then re add it to the database.I also would like to know how to easily delete a mysql row.And I want this done without going to phpMyAdmin.Thanks for the help!

Share this post


Link to post
Share on other sites

Hey there, for a basic example of UPDATE check this: http://www.tizag.com/mysqlTutorial/mysqlupdate.php

 

If you click on the "next" link then youll see an example of delete also.

 

i think its worth expanding on this part though:

 

// Get Sandy's record from the "example" table

$result = mysql_query("UPDATE example SET age='22' WHERE age='21'")

or die(mysql_error());

i dont like the WHERE part of this example so let me show how i would explain...

 

we will assume that there is a table of say usernames and passwords called "users" and a user wants to change their password. So of course they login and put the new password and click a button to change their password. the php code to edit the field "password" in the DB and change it to their new password would be like this assuming their username is "bob" and their old password was "bobspass" and their new password is "bobnew":

 

$result = mysql_query("UPDATE users SET password='bobnew' WHERE username='bob'") or die(mysql_error());

simple ;)

 

the syntax for update is:

UPDATE table_name SET field_name='New_value' WHERE field_name='Old_value'

and DELETE is:

DELETE FROM table_name WHERE field_name='a_value'

If you need help with connecting to the database etc just ask and we will be glad to help. I wont post it now but if you need any more help just ask!

Share this post


Link to post
Share on other sites

I know I have seen several tutorials on pixel2life about adding tables and info, can't think of the links of the top of my head but I have some others, I know posts some links about mysql db's but have to look for it later and let you know.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.