Jump to content

[SOLVED] Hyperlink in Table for editing information


peranha

Recommended Posts

What I have is a table with 3 columns, and in the first column, I have it linked to editpost.php? with the id behind it.  I need to somehow get that id into the editpost page to bring up the info in 3 text boxes for the user to edit.  Not sure as to how to do this.

 

Here is the table info that they will click on to edit items.

 

<TR><TD WIDTH="225"><a href='editpost.php?<?PHP echo $row[0]; ?>'><?PHP echo $row[1]; ?></a></TD><TD WIDTH="460"><?PHP echo $row[2]; ?></TD><TD WIDTH="70" align="center"><?PHP echo $row[3]; ?></TD></TR>

 

Here is the edit page

 

// create query

$query1 = "SELECT * FROM table WHERE commid = ?";

 

Not sure as to what to put in the commid = ?.

 

If anyone can help, that would be great.

 

Thanks in advance.

Link to comment
Share on other sites

You need to use the $_GET method to retrieve the id for each page.

 

Firstly, you need to change that link to something like editpost.php?comm=id

 

Then, you can select the result by inserting the following into your code:

 

$commid = $_GET['comm'];

 

Use $commid in your query, and all should work accordingly.

Link to comment
Share on other sites

Edit: Beat to it :P

 

You need to change your clicking part to this

 

<TR><TD WIDTH="225"><a href='editpost.php?id=<?PHP echo $row[0]; ?>'><?PHP echo $row[1]; ?>[/url]</TD><TD WIDTH="460"><?PHP echo $row[2]; ?></TD><TD WIDTH="70" align="center"><?PHP echo $row[3]; ?></TD></TR>

 

Now on the page where you grabbing the information to edit, you would simply do this

 

<?php

$id = $_GET['id'];
$query1 = "SELECT * FROM table WHERE commid = $id";

?>

 

 

 

 

 

 

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.