Jump to content

Help with PHP/MySQL database function


INeedAGig

Recommended Posts

Okay, I have been following this tutorial: http://www.freewebmasterhelp.com/tutorials/phpmysql/1 to achieve exactly what I wanted to get done. I also followed the way to have it formatted in tables and added extra columns that I needed, included an "Options" column which houses three links, including "edit" and "delete"

 

Now, I have everything working fine but I am stumped on how to get the "edit" and "delete" links to work for each individual entry that is listed. I have to have these features so the entries can be edited and deleted without having to physically go into the MySQL database to do it. The tutorial explains how to do it in Step 6, but I am confused. I'm not quite sure where to place the code for the links, which are generated automatically every time a new entry is inputted into the database.

 

Anybody available to help me out? Thanks! :)

Link to comment
Share on other sites

You can use get and make the links like this:

<a href="?action=edit">edit info</a>

Then write an if statement thats says

If ($_get["action"] == "edit";){

Info_edit($_GET["username"]);

}

function info_edit($username){

query database and fetch array of every member where username = $username

Use variables to display members information and do so in text fields

Enclose all info in form tags

<form action="?action=update&username=$_session["user"]" method="post">

 

</form>

if ($_get["action"]=="update") {

update_info($_get["username"];

}

Function update_info($username) {

process form information and update it in table where username=$username;

}

And that should work. Of course u mIte nneed to tweak it a bit...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.